Share My Creation atHome - App for Domoticz Home Automation

atHomeApp

Note: This app is replaced by the Domoticz Quick Viewer.

upload_2018-10-17_8-51-41.png

Note: in the meantime added more devices.

Objectives
To create a flexible Home Automation Android & Windows App to view & control devices atHome.
  • atHome is a private project building a Home Automation Solution
  • based on Domoticz Home Automation System v4, running on a Raspberry Pi 3B+ Stretch
  • atHomeApp is created with B4A v8.50 and B4J v6.51
  • Open Source GNU Lesser General Public License
  • first private showcase learning Mobile Development B4A / B4J + XUI
  • Make the app as generic as possible, means the data of the Domoticz server should be used as is without making dedicated changes in the app
  • Keep the App SIMPLE – not overcomplicating - fast access to view & control is key
  • B4J version here
  • Published on the Domoticz Forum
Functionality
  • View & control devices which are added to the Domoticz Dashboard ("favorites")
  • Devices are grouped and displayed in tabs (B4A TabStripViewPager Custom View, B4J TabPane)
  • Own device grouping used (not Domoticz menus) to build the tabs: Weather, Lights, Information
  • Tabs containing xCustomListView to view or control devices and to manage settings via CheckBox/InputDialog
  • xCustomListView items are build at runtime using Domoticz Favorite Devices data
  • Domoticz Favorite Devices data is requested via HTTP (okhttputils2) and the JSON rersponse is parsed to get the relevant data
  • Data refreshed is triggered manually via menu item (Tab Settings shows time refreshed)
  • If Domoticz favorite devices are changed (added/removed/updated), these are reflected on the next manual updated (no changes required in the App, full flexible to handle change)
  • Clicking on xCustomListView item shows short toastmessage with additional information
  • Tab Lights enabled to control switches (on/off), lights (on/off) and dimmer. When dimming, a short toastmessage shows the dim level. Mainly used for Philips Hue Bulbs
  • Tab Information enables to send a message to the Alert Message device via InputDialog
  • Settings are managed via Tab Settings and stored using map file (in file internal)
  • At App resume (B4A), data is refreshed
  • Menus added to refresh the data as mentioned, jump to tabs (pages)
Outline next version
  • Extend parsing device Types & Subtypes as not all Domotict types are supported yet
  • Handle devices thresholds, i.e. change data color depending level
  • Consider to update real time or use a timer to autorefresh - but will cause high network traffic
  • Consider selective devices from all devices data - needs customizing (=effort to maintain, non standard), high data volume
  • Various smaller improvements
Development Hints
  • To get started with xCustomListViews, view the very good video tutorial first - could not build the solution without the video!
  • Android.jar: ensure(!) to set minimum android-28\android.jar (else error unable to find attribute android:fontVariationSettings) - it was a surprise after updating the SDK - but solved with help from the forum
  • Use the Domoticz JSON/API reference for building URL requests
  • Use browser first to test and learn the properties of the URL requests & response from the Domoticz server
  • Screenshots made with the Android device monitor (folder tools, monitor.bat)
  • All constants defined in code module Constants, Tabs text & icons defined in a map with maps
  • Initial Development effort: 2 days (30% Conceptual Design on Paper, 40% Exploring How To Solutions, 30% Coding & Testing)
Source Code (B4A)
Attached without the libraries used
 

Attachments

  • athomeapp-b4a-v095.zip
    32.1 KB · Views: 575
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update v0.93 (Build 20181007) (see Post #1)

* NEW: Device recognize and mapping to tab defined in a JSON structure file stored in assets.
* UPD: Added more devices. More to add over time.
* NEW: Replaced option to send a message by using InputDialog when pressing/clicking on Art Device Item (Index defined in the settings).
* NEW: Tab Lights: Accept switch ON/OFF device
* NEW: Each device holds it full property list. Easier to access device information/state.
* NEW: Tested the app on a Raspberry Pi running emteria.OS - looks great on a 21" LED screen.
* NEW: Icon created.
* NEW: Developed B4J version with almost same code - only specific objects changed, add classes for InputDialog & ToastMessageShow.
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update v0.95 (Build 20181017) (see Post #1)

* Focus been on building further single code base for B4A & B4J using shared modules & conditional symbols.
* UPD: Settings layout rebuild using xCustomListView w/ items checkbox, labelbutton. Textual input via InputDialog.
* UPD: Layouts further aligned between B4A & B4J. Ensured to use hor & vert anchors.
* NEW: Code sharing between B4A & B4J for modules Constants, JSONParser.
* NEW: Code sharing between B4A & B4J in module Main (requires cut&paste and condidional defines). This solution is not optimal, need to explore better way.
* UPD: B4J improved classes InputDialog & ToastMessageShow (with long option) to be aligned with the build in B4A methods.

Screenshot B4A atHome app running on a Raspberry Pi 3+ with emteria.OS (Industrial Android), HDMI 21" display
upload_2018-10-17_8-58-23.png
 
Last edited:
Top