thomasloven / hass-browser_mod

🔹 A Home Assistant integration to turn your browser into a controllable entity and media player
MIT License
1.31k stars 187 forks source link

Entities become "unavailable" after 5 minutes #145

Closed hanzoh closed 3 years ago

hanzoh commented 4 years ago

I am using browser_mod 1.1.6 with HA 0.116.2 and have a Galaxy Tab A as a wall-mounted dashboard, running LineageOS 17.1 (Android 10) with latest Fully Kiosk Browser and WebView.

I have setup browser_mod like this:

browser_mod:
  devices:
    398e7aa2-9f66b227:
      name: tablet
  disable:
    - all

As long as the tablet is showing HA, the entities are available (binary_sensor and light are "on"). After the 10s timeout defined in Fully Kiosk Browser to turn off the screen, the light is switching to off. In Android, I have disabled all screensavers and power saving settings, I have kept the screen timeout at 1min, as there is no option to disable it completely. When I move in front of the tablet, Fully Kiosk Browser's motion detection turns the screen back on and the light entity goes back to "on".

But when I haven't moved in front of the tablet for about 4min30s in front of the screen, all entities become unavailable.

I have already disabled this setting in the HA user settings:

Automatically close connection
Should we close the connection to the server after being hidden for 5 minutes?

Is there anything else I can configure to keep them available? Otherwise, I cannot interact with it in automations when the tablet's screen is off. My plan was to activate the screen when someone rings the doorbell and then show the front camera's more-info screen.

KTibow commented 4 years ago

What Android OS? 10? 9? 8? Does Fully have an option to disable falling asleep?

hanzoh commented 4 years ago

I am using browser_mod 1.1.6 with HA 0.116.2 and have a Galaxy Tab A as a wall-mounted dashboard, running LineageOS 17.1 (Android 10) with latest Fully Kiosk Browser and WebView.

Android 10, and Fully's 'Avoid sleep when display turned off' is enabled.

KTibow commented 4 years ago

Maybe tied with #140

hanzoh commented 4 years ago

I checked the issue you have referenced, and did a downgrade to the stock Android 8.1 image. Unfortunately, the problem is the same.

hanzoh commented 4 years ago

I have checked my Unifi controller and it reports continuous WiFi connection of the tablet. When the entities are "Unavailable", I can still ping the tablet's IP. So can I assume that the tablet is not sleeping then?

KTibow commented 4 years ago

No, it's sleeping, might still be connected to WiFi, but not Home Assistant.

SamMousa commented 4 years ago

I have the same issue, it seems the webview becomes inactive

Nicxe commented 3 years ago

Same issue for me as well. First I thought it had to do with the automatically close connection after 5 minutes but it doesn't help to turn that off, still the same issue.

thomasloven commented 3 years ago

I believe I have kind of nailed this one down - or at least found an imperfect workaround.

From what I can tell, FKB loses connection exactly five minutes after the screen has turned off, whether from a timeout or through browser_mod. The workaround I have found is to turn the screen on and off again every four and a half minutes. Obviously, this is not a perfect solution, as it will make your screen flash, so it will be opt-in via

browser_mod:
  devices:
    12345678-90abcdef:
      force_stay_awake: true

Debugging timeout related things is really really really annoying, so I'll let my setup run over night (yet) again, and may release the fix tomorrow (CET) it it seems to work.

Nicxe commented 3 years ago

Don't know if this means anything, but I have automation to restart Fully Kiosk at 4 every night. I now notice that the tablet hasn't got unvendible until 5 min after the motion was triggered the first time. And that happens after every time I restart Fully Kiosk browser IMG_2223

thomasloven commented 3 years ago

1.2.1 has been released with the workaround.

After restarting but before motion trigger; does it react to commands like turning on the screen?

Nicxe commented 3 years ago

After restarting but before motion trigger; does it react to commands like turning on the screen?

Yes it is

Nicxe commented 3 years ago

This work around got my FKB to freeze while reloading when motion triggers the screen to light up

SamMousa commented 3 years ago

Just to be sure, did you guys disable the hass option to disconnect?

Nicxe commented 3 years ago

Just to be sure, did you guys disable the hass option to disconnect?

Yes, doesn’t help

SamMousa commented 3 years ago

@thomasloven I think I stumbled on a better work around, I found a library for creating wakelocks: https://github.com/richtr/NoSleep.js

This library does something different, but it inspired me.... I added this to FKB advanced web settings: image

This essentially plays a silent mp3 audio file, this is just a test using some random mp3 file i found using google... Probably a smaller one could be used and looped...

It looks pretty good: image

Could this be a good solution moving forward?

SamMousa commented 3 years ago

Second attempt:

var audio = new Audio('https://raw.githubusercontent.com/anars/blank-audio/master/45-seconds-of-silence.mp3');
audio.loop = true;
audio.play();

image

Going on 30 minutes and it is still reachable!

Note: second attempt was just to test if looping works as well, this allows us to have no time limit AND use a smaller mp3 file. I suspect that length of the mp3 file is a tradeoff between CPU usage and file size, but it is probably negligible as long as we're not looping 0.1 second mp3 files...

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

SamMousa commented 3 years ago

Bump

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

thomasloven commented 3 years ago

Looping an audio file will prevent the device from turning the screen off.

Try the new option to control the screensaver instead of the screen mentioned here: https://github.com/thomasloven/hass-browser_mod#my-fully-kiosk-browser-device-goes-unavailable-after-the-screen-has-been-turned-off-for-five-minutes

maretodoric commented 2 years ago

Hello. Bumping this since there are no new updates. I've tried both official workarounds (force_stay_awake and screensaver) none works. I have screen off disabled but screensaver is lighting up after 15 seconds of inactivity. If screensaver is left uninterrupted for 5 minutes, entities will become unavailable. I haven't tried using silent mp3 play loop and would like to avoid it if not necessary.

saxopwn commented 2 years ago

force_stay_awake doesn't seem to be working for me either

pickonedev commented 2 years ago

Anyone have found a good solution to this?

SamMousa commented 2 years ago

I use the fully kiosk api

pickonedev commented 2 years ago

I use the fully kiosk api

Can you explain more?

SamMousa commented 2 years ago

I use a tablet that runs fully kiosk browser. So the control I need for the tablet I get via the api of that browser instead of this addon.

pickonedev commented 2 years ago

I use a tablet that runs fully kiosk browser. So the control I need for the tablet I get via the api of that browser instead of this addon.

I use Fully Kiosk Browser as well, on my tablets, but I don't know how to achieve things with Fully, which are done with browser mod...

I use this to cancel toast notifications and to auto-reload lovelace if I do changes to the dashboard:

 - service: browser_mod.lovelace_reload
 - service: browser_mod.toast
    data:
      message: Lovelace Reloaded
      duration: 1

Then, I use this to open the camera from my doorbell, when someone is ringing at the door, without opening other tab/page from HA:

      - service: browser_mod.more_info
        data:
          entity_id: camera.camera_door_frigate
          deviceID: ed1393d4-02cbd091
          large: true

There is any way to do this only with fully?

And about fully browser, sometimes I need to restart the tablet because it won't refresh the dashboard... and if I do it manually, it won't load the page anymore...

SamMousa commented 2 years ago

Check the api docs on their website. Navigating and even rebooting tablet is possible.

pickonedev commented 2 years ago

Seems that Fully can't do what I use from Browser Mod :-(

jouster1974 commented 2 years ago

Check the API docs on their website. Navigating and even rebooting the tablet is possible.

are you able to elaborate on this at all as myself and others may not be aware of what needs doing...thanks in advance

T3chArmy commented 2 years ago

Second attempt:

var audio = new Audio('https://raw.githubusercontent.com/anars/blank-audio/master/45-seconds-of-silence.mp3');
audio.loop = true;
audio.play();

image

Going on 30 minutes and it is still reachable!

Note: second attempt was just to test if looping works as well, this allows us to have no time limit AND use a smaller mp3 file. I suspect that length of the mp3 file is a tradeoff between CPU usage and file size, but it is probably negligible as long as we're not looping 0.1 second mp3 files...

After spending all day trying to find a solution for this, this code mentioned above works perfectly to solve the issue!

One important note that I was fighting with all afternoon that I didn't realize I had on, make sure "Consider Device in Use while Audio Playing" is not turned on in Other Settings. It's working great now!

ldc2335 commented 1 year ago

Second attempt:

var audio = new Audio('https://raw.githubusercontent.com/anars/blank-audio/master/45-seconds-of-silence.mp3');
audio.loop = true;
audio.play();

image Going on 30 minutes and it is still reachable! Note: second attempt was just to test if looping works as well, this allows us to have no time limit AND use a smaller mp3 file. I suspect that length of the mp3 file is a tradeoff between CPU usage and file size, but it is probably negligible as long as we're not looping 0.1 second mp3 files...

After spending all day trying to find a solution for this, this code mentioned above works perfectly to solve the issue!

One important note that I was fighting with all afternoon that I didn't realize I had on, make sure "Consider Device in Use while Audio Playing" is not turned on in Other Settings. It's working great now!

Where does this code go?

I'm having the same issue with disconnects after 5 mins. Chromebox 3 running HA android companion app.

KTibow commented 9 months ago

I believe you need to put this in your www folder, then add a custom resource (frontend -> custom resources) using /local/[filepath].js.

cedricdelecole commented 8 months ago

So there is no solution for this I understand, unless putting this code above in the "Advanced Web settings" ?

Something I do not understand is that when the screen if OFF, running an automation like the one below which is turning the screen ON then launching browser_mod.popup is NOT popping up the screen .... It does only if the tablet screen is already ON when the automation is launched ?!?

`- id: 4cf62087-4164-4685-be6d-2ede8401d5fa alias: Dahua VTO trigger:

janstadt commented 7 months ago

Any updates on this without the cycling of audio?