MBW.BlueRiiot2MQTT icon indicating copy to clipboard operation
MBW.BlueRiiot2MQTT copied to clipboard

Seperate weather updates as these can fail independently

Open ggggh opened this issue 3 years ago • 8 comments

Had this setting (BlueRiiot__ReportUnchangedValues: "true") working fine, but suddenly stopped working yesterday, and now unchanged values are no longer reported. This happened without any sort of change on my side, so assuming the API changed somehow?

ggggh avatar May 26 '21 13:05 ggggh

Magically working again now! I'll close, and will reopen if it happens again

ggggh avatar May 26 '21 17:05 ggggh

There is a risk that some of the logic conflicts. F.ex. I do a lot of comparisons to ensure I don't resend identical values (what this setting negates).

I can imagine a situation where where the same (new) value is read twice, there is a risk that the second read could be "identical" to the previous (also new) reading. Not sure how this plays out in code, but it seems likely that it either would be the case that the setting doesn't (always) work - or that it seems like it doesn't work.. :)

Do report back if it doesn't work.

LordMike avatar May 27 '21 08:05 LordMike

It started working again when I restarted the docker container, so I assume it had got itself in some sort of mess :) It had been running for over a month repeating those values well, so maybe some strange value combination suddenly triggered it...

ggggh avatar May 27 '21 09:05 ggggh

Happening again today. Would any logging or output help before I restart docker again?

ggggh avatar May 29 '21 10:05 ggggh

Actually, now have a feeling it is related to what I thought was an unrelated error on not being to get values for weather, as it sort of matches the same timeline System.Exception: API responded with an error: Cannot read property 'current' of undefined. The app is not able to get the weather data either, so retrieving it is not a problem in your code, but maybe you need to handle that exception differently as it is then affecting the ReportUnchangedValues functionality?

ggggh avatar May 29 '21 10:05 ggggh

Ah, I see. Nice to know also, that their serverside thingy is likely javascript :P

When that exception occurs, the entire update loop will be disrupted (and run again later). You should see values like last_bad on the operational sensor in HASS. See https://github.com/LordMike/MBW.BlueRiiot2MQTT/blob/b6a71ba204141cd6fb1e520b04576ac0222b2c3f/MBW.BlueRiiot2MQTT/Service/PoolUpdater/SingleBlueRiiotPoolUpdater.cs#L92-L97 for details.

It will affect the unchanged logic, as after the exception occurs, the call to MarkAllValuesDirty won't happen.

But then again, once the error subsides, all values should again be pushed.

Actually, I now see another issue: When a pool (any pool if you have several) is updated, then all values are pushed again, even the ones that weren't updated... Like another pools values, or the other sensors BR2MQTT provides... Should probably change that to just the sensors that could've been updated.

LordMike avatar May 29 '21 10:05 LordMike

By the way, the weather update on the app is working again, and as expected ReportUnchangedValues also working now.

ggggh avatar Jun 02 '21 10:06 ggggh

I've made some code that splits out the weather updates from the regular pool updates. Turns out this is a seperate API call for BR, so it can fail independently of everything else. Will test it out myself, and then tweak a bit more.

I've also made it so that the weather updates can operate at a different interval than the regular updates. I think maybe the weather doesn't change all that often .. :)

LordMike avatar Aug 25 '21 20:08 LordMike