custom-cards / surveillance-card

A custom component for displaying camera feeds in the style of a surveillance system.
Apache License 2.0
244 stars 36 forks source link

Main camera stream not present at the beginning + Login failed #29

Closed Luke95vl closed 2 years ago

Luke95vl commented 4 years ago

after updating to the latest version the image of the main camera does not appear, the broken image icon is present, while the mini thumbails work regularly. If I wait 15 seconds the image appears but at every page refresh the problem persists. In addition, every time I try to access the surveillance screen I receive a failed login notification from the IP of the device I am using. In the logs is reported

Logger: homeassistant.components.http.ban
Source: components / http / ban.py: 75
hsolberg commented 4 years ago

I get the same exact problem. I think it might be related to this perhaps: https://github.com/custom-cards/surveillance-card/issues/22#issuecomment-654212714

cben0ist commented 4 years ago

Same issue for me too.

niemyjski commented 4 years ago

Is it due to the main image not having an access token? I've seen this happen once but haven't been able to track it down? Other than this is it working ok? We should be able to do some really cool stuff now that we have state and info on every camera.

Luke95vl commented 4 years ago

I don't know if it needs access, my knowledge is limited in this field, the main image works after 10/15 seconds that I have accessed the page, the rest works all

niemyjski commented 4 years ago

Sorry for taking so long to respond I've been pretty busy but tried to see if I can see this behavior, but haven't really had time to track it down. I wonder if it has to do with the camera_stream_proxy taking a little bit to get ready.

niemyjski commented 4 years ago

It would be a huge help if someone could dig into this.

niemyjski commented 4 years ago

Has anyone had time to look into this? When I first ran into this issue, it was due to the camera proxy stream not having an access token.

RoldyBuffalo commented 4 years ago

Heya, I seem to have the same issue. I'll edit this reply to include logs, unless you happen to reply before I hit enter.

Well, here is what happened, and continues to happen.

I open a panel with the integration as suggested and the cameras on the LEFT side load their respective images, the panel on the right side with the selected camera's large image then shows a broken image link icon at this time, after a period of about 5 seconds, I get this error

Logger: homeassistant.components.http.ban Source: components/http/ban.py:114 Integration: HTTP (documentation, issues) First occurred: 11:39:15 AM (1 occurrences) Last logged: 11:39:15 AM

Login attempt or request with invalid authentication from (My local router's IP address) (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36)

then after a period of 20~ more seconds, the RIGHT side image loads, if I do not leave this window/panel and dismiss the error, it does not pop up again. If I reload this window, the error pops up.

This poses a pretty big concern as having IP bans enabled in your login system would be ideal, and even preferred by most. This error causes the login to be banned (full stop.)

niemyjski commented 4 years ago

Seems like the token is invalid that we get back from the api. We are just using the access token that's provided in the state attributes. These bans are not idea. Can you please see if my latest commit fixes this for you: https://github.com/custom-cards/surveillance-card/commit/a1b1933ef7c1ae025380604dc9884d65243fefb6 If not, would you mind filing a bug on the HA repo and reference https://github.com/custom-cards/surveillance-card/blob/master/surveillance-card.js#L115-L119

lassealfastsen commented 4 years ago

i Have the exact same issue, did anyone fix it?

kkellner commented 4 years ago

@niemyjski The master branch seems to have fixed the issue for me.

niemyjski commented 4 years ago

Awesome! I'll try and tag a release

kkellner commented 4 years ago

I spoke too soon. The right side (large view) comes up immediately now, however after a view minutes I get banned. I'll continue testing.

kkellner commented 4 years ago

Looks like it has something to do with HA restart -- I have a tablet that has a lovelace view showing view withsurveillance-card. When I restart HA, after HA starts I get 1 failed login from the tablet. Then all seems to be OK. Since my HA is front-ended with an HA-proxy, all the requests look like they come from the same IP.

I suspect that if I have 5 devices (e.g., many tablets) that all will get 1 failed login each and all 5 devices look like the same IP because of my proxy setup, it will add the IP to the ip_bans.yaml file.

This doesn't explain why the IP ended up getting banned for me earlier as I only have the 1 tablet and I had 2 chrome tabs open on my laptop to a HA lovelace view that has surveillance-card. So even if it was 1 failed login per device/tab that would have only been 3 failed logins.

kkellner commented 4 years ago

@niemyjski I believe your change is good for getting a valid stream at first view. However it doesn't (fully) resolve the login failed issue. Some interesting discussion on the topic here:

https://community.home-assistant.io/t/wth-are-those-login-attempt-failed/219519/58

niemyjski commented 4 years ago

This seems blocked by https://github.com/home-assistant/frontend/issues/3379 which may be part of the core issue. We only use the token that is provided by the HA state. If someone can dig further and see what exactly is needed to get an up to date token from the state store or refresh update that would be a huge help. My time is limited but I'll do my best to get this resolved.

dustins1983 commented 4 years ago

Im getting this too, and for me it shifts the whole card to the right, so i have to scroll sideways to see the camera

niemyjski commented 2 years ago

I'm going to close this as it seems like it's resolved in core now via the linked frontend issue https://github.com/home-assistant/frontend/issues/3379 Please let me know if this is still an issue. Any help would be greatly appreciated.