Android Dash Board Browser with Motion Detection and MQTT

Might be possible but I have no device for testing it, even my five year old nook tablet runs Android 6.
Next build I try and will ask for your feedback.

Haha yes it does work. I suppose I didnā€™t say so but yeah seeing mqtt work isnā€™t much of a screenshot. Thereā€™s a pull request waiting for that and another toggle to turn off the page loading status; personally I donā€™t want that but others might.

I am using a rooted Fire HD6. I was using Cyanogenmod before however 4.x is the most that runs on it and the camera doesnā€™t work which is now an issue. Shame because FireOS is a lot slower but it will do. So to the comments in here about 4.x I didnā€™t play with compiling down, I also have no clue on the impact to APIs and such, Iā€™d imagine thereā€™s something to it. I think though it would be desirable as lots of useful old android tablets would be on 4

Other thoughts I hadā€¦

  • the json payloads for control appear to need to be {ā€œwakeupā€:ā€œtrueā€} or really any value since it isnā€™t evaled, since its json parsing. That made me think it wasnā€™t working at first. Iā€™m using mqttspy to inject by hand right now.
  • I didnā€™t see the jsaction one work yet
  • Iā€™m using another app to do auto start on boot but it probably makes sense for it to be in this app natively?
  • I could see doing a HASS component to support tablet dashboards or such, maybe thereā€™s a spiritual pairing on the iOS side to sync up with, or maybe create. Again the MQTT stuff was a great idea!

How could i build it my own? can u post a short how to `?

if you could tell me how to create it myself, i could try.
but if not i am happy to test, when you create it.

Another thing Iā€™ve noted this morning. If the cycle is to allow the device to lock, then the app is effectively not running in the background, or not updating as the camera wake does work. When itā€™s back the widgets are in inaccurate states :frowning: not sure of the effect on MQTT commands either

So I guess four thoughts

  • keep the app running appropriately when itā€™s locked
  • donā€™t allow a lock at all and turn of the screen some other way?
  • accept the screen will never turn off and use the keep awake dev setting. Iā€™d prefer to save the backlight tho
  • force a page reload. Which is adding a delay but I guess itā€™s more appropriate than running the screen

Personally I think the second idea seems like the easiest/best outcome, but not sure if itā€™s feasible for an app to do that.

This looks pretty awesome! I think I need to get some wall mounted tablets as well :slight_smile:
Runs nicely on my Huawei M2
Does this app also run on amazon FireHD?
Or does anyone have a tip for a nice looking cheap 7 inch tablet. At best in the EU.
Might it be possible to implement a zoom function?

For me it wakes up even after a full day out. Wakeup only works while in the browser activity but not for the settings.
things to check

  • is doze mode interfering? Some Android version are pretty aggressive about stopping applications. Try to disable battery optimization in the Android settings
  • is the motion detector working at all? Maybe the app uses the wrong camera :wink:
  • does waking up via MQTT work for you?
  • does URL work for you while display is off?
  • do see something interesting in the logcat?

I went for screen off since my Nexus 10 discharges even when connected when the screen stays on and itā€™s another 2 watts more consumption. If you want to force keeping the screen on the wakelock is already implemented for waking it up. Currently itā€™s removed immediately again. See HomedashService->wakeup.

Seems like i force everybody around into Android Development :smiley:

Download the source build it with Android Studio.
Review \homeDashApp\build.gradle relevant setting should be
'minSdkVersion 22

See here https://en.wikipedia.org/wiki/Android_version_history for the version. The motion-detector lib requires at least SDK15 so Android 4.0.4.

Good luck.

If someone manages to rebuild it for ither anbdroid versions please upload it somewhere for the rest of us to give it a try

While integrating the changes of @quadportnick i tried build for older version but everything below API 21 Android 5.0 requires a different implementation of various features. Itā€™s nothing that canā€™t be done.

Since all my devices work it is really low prio for me. Letā€™s hope for volunteers.

New apk: https://github.com/ray0711/homeDash/releases/tag/0.2

1 Like

i have installed android studio (in the past)
i downloaded and imported the code, but i have no clue how to build.

since you mention that different implementations are required, i guess i am not able to make a lower version.

so all i can do is hope that someone else does it.

The apk is working for me, i just need to find time to get to know it better

OK works but i cannot see mqtt topics in my broker but nice beginning!!!

Itā€™s not that it doesnā€™t wake, its that while it was locked (asleep), nothing updates in the webpage. The Web UI comes back in completely the wrong state of things. eg, if lights were switched while it was asleep, the dashboard shows the completely wrong state. As you said I think its the OS being aggressive with not letting the app process while itā€™s locked, which I get. I havenā€™t played with the mqtt behavior, which may be better off.

The ā€˜alternativeā€™ for me in the past was to have the dev mode set to not allow sleep when plugged in. The screen dims but it certainly doesnā€™t turn offā€¦

In all cases the camera detection wakes it fine. I just donā€™t want it to have to run the backlight, ya know? :slight_smile:

I dont have many options on FireOS, but it is rooted. (eg, I was able to remove the lockscreen entirely. Thatā€™s not an option the OS allows in the UI, but, itā€™s possible to do it underneath. If the lockscreen is enabled, the camera wake just comes back to the lock screen and you have to swipe it to unlock which is obviously not desirable). I could go back to Cyanogenmod I suppose if we could get this built on Android 4.x, but, from what I read the front camera is broken on this model soā€¦ :smiley:

Ok, I did some searches and Iā€™ve got some mods to how the wakeLock stuff is setup, and Iā€™m not using the window flags at all. So far, it seems to work, at least for my deviceā€¦ but it will need the overnight test. UPDATE: Still not good. But I think the issue is: WiFi is being turned off! Playing with locking WiFi now.

All the MQTT stuff and updating seems to happen fine while the screen is off now ā€“ and i can push in a new URL and when I wake it (camera or MQTT) poof, the new page is there. I dont know why that seems magical :slight_smile:

Edit: Ok I should quit tonight. I have implemented the following in my fork:

  • Hopefully better locking/unlocking code for my tablet at least, but this needs to be tested
  • Fixed a typo with jsExec which made it not work
  • Fixed a quirk where going back to settings keeps punting you back into the browser if you have start with browser enabled
  • Added an option to auto start on Android startup
  • Added a save option to the URL command, so it saves that URL as the new startup url

https://github.com/ray0711/homeDash/compare/master...quadportnick:master

Thatā€™s just plain great!

I think a switch for more or less aggressive wakeup in the settings would be cool. Then we can keep both versions and everybody can choose himself.

Exactly what I was thinking. I have a situation where this is important, but it will suck more battery in a non tethered situation. And different tablets have different behavior

Wifi locking seems to have been the trick. I saw it posted sensor data all night, and when I woke it up with the sensor the dashboard state was correct. So I guess the previous locking kept the App alive however the networking was not. :confused:

Will clean this up tonight!

Iā€™ve posted a test release of the changes I made to 0.2, can some folks please try this and see if there are any behavior regressions? (ray ā€“ do I need to post a signed copy for others to sideload? Iā€™ve not had a problem so far)

0.2-qpn Test

  • New code for screen locking
  • WiFi Locking option
  • Option for prevent screen sleep entirely
  • Added save option for MQTT url command
  • Added option to start homeDash when device boots
  • Auto-browser only activates when first starting app
  • Fixed jsExec MQTT command typo
  • Added reload MQTT command

Afaik: no signing required for the debug version. Only if you set the build to release.
You can create a new (self signed) signing key in Android studio. Should be somewhere in the build signed apk dialog.

I guess iā€™m gonna switch to your version over mine :slight_smile:

@ReneTode what version of Android exactly do you have on those tablets?

It looks like they moved to the Chrome engine for default webView rendering around 4.4, I have a feature-broken version of homeDash running on 4.1 and the way the browser works is SUPER miserable and not going to work well at all with HADashboard. I donā€™t know yet if I can grab Chrome separately and embed it in the app, might be a way, but the ā€˜easiestā€™ route would be to use 4.4