appdaemon icon indicating copy to clipboard operation
appdaemon copied to clipboard

AD 4: Camera widget

Open Laboss opened this issue 5 years ago • 10 comments

Hello

After installing AD 4 I put the camera widget and so far so good!

The problem now is, if you restart HomeAssistant the IP of the tablet running Dashboard is banned!

I think it's because the camera token has changed and the dashboard didn't reflect this change!

Maybe it was better to detect if the HA was relinquished and force the camera token update

Thanks

Version | 4.0.0b2

Laboss avatar Jan 03 '20 09:01 Laboss

dashboard cant know that you restart HA, and even if we modify dashboard so that the HA start event is noticed and all dashboards automaticly get reconnected, we get the same trouble as with apps. HA gives its events before all components are completely setup. so the risk is that at that point a lot of widgets get an error because entities are not setup when the dashboard is loaded.

the best way to go is to set the dashboard in HA as trusted, so it wont get banned.

and create automations that the dashboards are reloaded some time after HA has been restarted.

ReneTode avatar Jan 03 '20 12:01 ReneTode

Its not possible handle 403 error when token got invalid first time?

Is there any api that can force dashboards to reload?

Thanks for reply

Laboss avatar Jan 03 '20 13:01 Laboss

there is no api that forces dashboards to reload. you can add headscripts to a skin to handle that, or like i do: use fully kiosk and use that to reload the dashboards.

i dont know how the widget should check for the 403 error. but at that point its already to late, because dashboard would only change the token after it would have tried to logon with an invalid token, and then its blocked.

making sure that HA just never blocks your dashboard is the easiest way.

ReneTode avatar Jan 04 '20 03:01 ReneTode

@ReneTode I'm trying to whitelist my dashboards to bypass this problem with

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.29.3/32
        - 192.168.29.6/32

but they are still getting banned. Am I missing something?

ajitam avatar May 02 '21 18:05 ajitam

i dont know. how is the camera setup in your dashboard?

ReneTode avatar May 02 '21 21:05 ReneTode

well camera is set like this

camera:
  widget_type: camera
  entity: camera.bedroom
  base_url: https://url.to.ha.cm
  refresh: 1

I thought this was just a matter of whitelisting IP of the tablet showing dashboard

ajitam avatar May 03 '21 06:05 ajitam

guess trusted_networks don't work :/ ☛ https://github.com/home-assistant/core/issues/37029

ajitam avatar May 03 '21 08:05 ajitam

no your problem is your refresh setting. refresh is only there to make sure that a cam with independable connection renews its connection. refresh set to 1 makes that on a slower network the cam widget gets an old token from the entity.

remove refresh and your problem will most likely be gone. it can still happen at some moments though, because its a race situation. HA changes the token every time, and the time between the moment that HA renews the token, and the dashboard getting the token can always give trouble.

the only way to change that is if the cam widget is changed so that everyone uses a long lived token and puts it on the dashboard. but thats not really a wanted option.

oh, and dont forget to add: stream: "on" which will make that the cam will be streamed.

ReneTode avatar May 03 '21 10:05 ReneTode

Great. It works (for now at least). Have to say - I'm a bit confused with whole, streaming/refreshing/... combination

but, anyway, thanks!

ajitam avatar May 03 '21 11:05 ajitam

ill explain it more then.

for example, i got 1 camera but for some reason on a particular tablet the camera stream stops after 3 or 4 minutes. every time. so off course i can restart the dashboard, but obviously i dont want to do that. so i set refresh to 180 (seconds) in that case every 3 minutes the connection to the camera is renewed. and it continous constantly.

hope that makes it more clear. and please close the issue.

ReneTode avatar May 04 '21 00:05 ReneTode