TheTimeWalker / wallpanel-android

WallPanel is an Android application for Web Based Dashboards and Home Automation Platforms

Home Page:https://wallpanel.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] currentURL MQTT push

starkillerOG opened this issue · comments

Link to the feature request in the old repositry: thecowan/wallpanel-android#334

Your feature request. Please describe.
What is the feature, why is it valuable to the community or application?

The current URL that is displayed in the app is published on the /state topic on MQTT inside the json message with key currentURL.
This is greath since it allows for some nice automations using HomeAssistant in combination with the {"url": "http://"} command.
However the current URL is only published every x seconds which is configurable in the WallPanel settings.

I would very much like the currentURL to be published to MQTT immediately on a change of the URL in the application.
This is already done for the motion and face detection topics, so I think it schould also be posible for the /state topic on URL changes.
This would allow for even nicer automations and more control using automations in HomeAssistant.

Thank you very much for the greath app, keep up the good work, much appriciated!

NOTE
We get many feature requests, each feature requires community support and also development time. Features that have no community support are not considered. If you are not contributing to the feature, then the feature may not happen.

That's strange. From my testing, I see that the state gets pushed immediately when the URL changes. There is a 3 seconds cooldown so that the MQTT broker doesn't get spammed from too many state changes.

@TheTimeWalker I just updated to your latest release, but still do not see immediate URL change state updates.
I do have face and motion detection enabled, so maybe that is causing a lot of MQTT messages which is preventing the URL change to push???

How does the motion/face detection work?
Does it keep sending MQTT messages when face/motion is detected or does it only send 1 message when face/motion detection is True and then only send 1 message after face/motion detection is false for x seconds?

I have face detection activated as well, and I get instant state when the URL changes. Have you tried listening for /state messages to see if it properly works? That's where the URL changes.

The app itself is changing the state as soon as it detects an intent that the URL in the webview changed. This runs the function to send an MQTT message as well. Exception if the state was sent in the last three seconds. Probably something that could be made better, but it should still be pretty much instant at other times. Face/Motion works similarly where if it detects a change, it immediately sends an MQTT message. After 30 seconds (seems to be configurable), it automatically sends a false message.

Maybe something good to know what Android version are you running? Perhaps there was an API change there.
[Edit] Just saw that you're running Android 11 on the other issue.

@TheTimeWalker thank you for pointing me in the right direction (stupid of me not to check this before).
I held a laptop with a connection to the MQTT broker next to the tablet and looked at what happened.

Once every +- 15 seconds I get a new \state message (that is because I set the sensor updates to 15 seconds).
As soon as I press a new tab on lovelace (change the URL) I indeed see a new \state message comming in.
However this message that is pushed immediately contains the old URL (the URL at which the tablet was before pressing the new URL).
This message arrives very fast on the broker (I see the message apearing even before the tablet is done rendering the new page).
Then if I don't do anything the URL will change to the correct (new) URL after a time of max 15 seconds (the new state update).

Diffrent situation: I begin on URL1
If I press a new URL2 (I get a state message containing URL1), wait 4 seconds and then press URL3, I immediately get a state message containing URL2 (instead of URL3), so lacking behind one URL, I do get this message before the scheduled update of every 15 seconds.

Other senario: I begin on URL1
I press a new URL2 (receive state URL1) and then press a another URL3 within 2 seconds, I do not get another state update and have to wait untill the next sensor update +-15 seconds and then receive URL3.

So there are 2 problems in my vieuw:

  1. the state push after a URL change does not contain the new URL but rather the old URL, maybe because the tablet is not done rendering the new URL?
  2. URL state pushes within 3 seconds are ignored, I would like to see an exception for URL state pushes, since they only occur when a user is pressing buttons on the tablet. In the real world the user is most likely not able to press buttons faster than the MQTT broker can process the messages. Therefore I would like to have all URL changes beeing pushed.

@TheTimeWalker thank you so much for looking into this and your greath work so far on this project!
If I can do any debugging please let me know.
Unfortunatly I have never programmed with android applications, so I will not be much help there.

Interesting, thanks for the info. It's possible that the intent does actually just give the info of the old URL instead of the new URL accidentally and I haven't seen this correctly. I will look into this again and see if there is a possibility for optimizations there.

@TheTimeWalker did you mange to reproduce the behaviour I explained?

Sorry, I haven't looked into this deeply yet. Will do this soon!

@TheTimeWalker gentile reminder, would be awesom if this could be fixed :)

Sorry 🙈
Will look into this in the next days now!