elad-bar / ha-blueiris

Integration with Blue Iris Video Security Software
183 stars 42 forks source link

Integration keeps appending "_2" to the end of the entities #149

Open PMaxx-Gaming opened 2 years ago

PMaxx-Gaming commented 2 years ago

My logs keep filling up with "Stream not found" errors and when I look at my entities in developer tools I'll see that all of my cameras have duplicate entities with the original one not working and the duplicate (with "_2" appended to the name) being tied to the integration.

This forces me to restart HA, reload the integration and then rename all of my cameras to remove the "_2" from the entity.

This happens more than once per day.

kramttocs commented 2 years ago

Hey @PMaxx-Gaming , How long has this been happening? Have you been using the integration for awhile? Any thoughts as to what action is causing the duplicates? Are you making changes to the integration options? Thanks

PMaxx-Gaming commented 2 years ago

I've been using the integration for a year or so, and it's been happening for at least the past few months, I'm not really sure though. I haven't changed anything and can't figure out what seems to be causing it; I haven't had any issues with BI itself, just this integration.

kramttocs commented 2 years ago

Thanks. I am not sure what would cause this but I'll look at how the entities are created and maybe something will stand out. Odd that I haven't seen it and I've been poking around with the integration pretty heavy the past couple of weeks. If you happen to play around and get it to create more duplicates, let me know.

kramttocs commented 2 years ago

Looks similar to #111

PMaxx-Gaming commented 2 years ago

Will do. It seems to just happen randomly; sometimes restarting HA and then reloading the integration gets the feeds back on my dashboard, but I've had to reinstall the integration to get them back in the past. I just noticed the duplicates yesterday and realized that's why they weren't showing on my dashboard when this issue would pop up (because the working cameras had "_2" on the name, and my dashboard feeds did not).

PMaxx-Gaming commented 2 years ago

Yes, that looks like the same issue

kramttocs commented 2 years ago

Oddly enough I noticed this happened to me this evening. Some observations: When it occurred I looked at Devices and all of the broken ones (no _X) showed an integration of Camera or Binary Sensor. The working ones (_2) shows Blue Iris NVR I did a Reload of the integration and the _2 ones disappeared and the no _X ones started working again.

Will keep looking at this one as that is pretty annoying especially if one sets the BI profile as part of their HA alarm system.

PMaxx-Gaming commented 2 years ago

I did a little digging this morning and noticed that I had "Stream not found" errors twice in my HA logs last night and at some point lost all of my camera feeds due to the duplicate issue. I checked my BI logs and roughly 60 seconds before the stream errors in HA my Blue Iris logs say "APP - Restarted after unexpected shutdown". This happened both times I had errors in HA

PMaxx-Gaming commented 2 years ago

Also, I just noticed the duplicate ("_2") streams have a different session ID and access token from the previously working streams (the ones without "_2").

kramttocs commented 2 years ago

Good info. I added some logging to my test build last night but of course mine didn't show the issue. It does look like it does a lot of re-creating of the mqtt entities so I'll see if something can be done about that.

You are seeing the BI log message about the unexpected shutdown in the BI Status > Logs window?

PMaxx-Gaming commented 2 years ago

Status > Messages > Open File (I have log to file enabled)

pjponymoore commented 2 years ago

I've been having same issue for a while now. Any help would be grateful. If i can assist with anything let me know

thanls paul belfast

kramttocs commented 2 years ago

Hey Paul, If you can find any pattern - either in HA or BI itself, that would be great. I see elad-bar made some changes in the new shinobi code that might help with this? I am going to try this weekend to see about porting those over.

pjponymoore commented 2 years ago

Thanks for speedy reply

I will try recreate issue today. i thought it was every time i restarted HA, like after updates etc, but not so sure now after a couple of forced restarts today. i have totally re installed blueiris components in HACS/HA this morning to see if this makes any difference. Thanks again for your reply

Paul Belfast

kramttocs commented 2 years ago

Hey Paul, Can you manually copy the files from here: https://github.com/kramttocs/ha-blueiris/tree/changes-from-shinobi-repo and overwrite the ones in your HA instance? I pulled over some changes from elad-bar's Shinobi repo that I thought might be helpful. The piece of note are changes around deleting entities. I am wondering if that will have an impact on this behavior. I am not sure the original reason behind deleting the entities so often.

Do note that this has the changes from 1.0.11 (released today) in it which has an important note about the integration/server name.

Thanks!

pjponymoore commented 2 years ago

Hi Kramttocs

Done that this morning, After re-installing everything from scratch yestermorning, i couldn't reproduce error. I tried many HA restarts but still couldn't get it to rename entities. dunno if it was cause i re-setup hacs and integrations. Ill keep you upto date with how this performs with new files installed.

Again thanks for your time!!

paul

PMaxx-Gaming commented 2 years ago

I ended up having to reinstall the integration last night because all of my BI entities suddenly became unavailable, and no matter how many times I reloaded the integration and restarted Home Assistant, I couldn't get my Blue Iris entities to work

kramttocs commented 2 years ago

Didn't happen to get a log, did you? Someone else reported similar so am concerned there is something going on with the changes in 1.0.11.

PMaxx-Gaming commented 2 years ago

I didn't, sorry. It was right before I went to sleep, but it happened before I installed the new update. 

kramttocs commented 2 years ago

OK, keep me updated. 1.0.11 wasn't supposed to be a breaking change that required a reinstall.