Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue63 #65

Merged
merged 2 commits into from
Oct 26, 2023
Merged

Issue63 #65

merged 2 commits into from
Oct 26, 2023

Conversation

Memphiz
Copy link
Contributor

@Memphiz Memphiz commented Oct 6, 2023

This fixes the none working picture in home assistant. (issue #63 )

The reason why this was not working is some sort of race condition.

The current architecture updates the sw and hw fields of the ha_info class when "mqtt_sendBoxEvent" is called. Here seems to be a problem (which has a root cause I sadly was unable to find due to lack of time). It seems that hw and sw fields are alternating between empty and sane values. This results in 2 things.

  1. If hw is empty it will result in invalid json syntax for the home assistant autodiscovery topic (because hw is the last property in the json and is supposed to "close" json struct properly). I fixed this by allowing to publish empty values inside json which is a valid thing to do imo. This leads to valid json even if "hw" property is (still) empty.

  2. The fact that the json content is changing all the time (because of alternating hw and sw properties) results in the fact that home assistant updates its internal device structures. It seems it unsubscribes from the topics (state and url) as well and resubscribes to them immediately. The fact that teddycloud pushes its state and url topics (for example the picture url) instantly after publishing the auto discovery topic seems to lead to the fact that home assistant misses that state change of the url. I fixed this by only updating sw and hw fields in case they are still empty. Using retained messages on teddy cloud side might fix this too - but I don't like those messages because the can get messy on the broker ;)

I know that the fix for the 2nd problem is not ideal. No problem if you don't consider this feasible to merge - but I use it for myself so I thought I would at least propose it here. :)

… we might mess up json syntax. (fixes broken json when "hw", which is the last json entry, is empty)
…ey are still empty. This ensures that the message stays static at one point so home assistant doesn't update its internal device structures (leading to race conditions which prevent the picture from showing for example)
@SciLor
Copy link
Contributor

SciLor commented Oct 6, 2023

Thank you for your fix and your detailed problem analysis.

We will try to integrate it, Currently it isn't building, but I will check that.

@SciLor SciLor merged commit 111a525 into toniebox-reverse-engineering:develop Oct 26, 2023
2 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants