-
Notifications
You must be signed in to change notification settings - Fork 6
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
Monitor as switch, linked command with sensor, battery fix #37
Conversation
Hi @infeeeee, your solution was in the right way, correct to edit only the configurations for hass and not also the way states are sent. |
IoTuring/Warehouse/Deployments/HomeAssistantWarehouse/HomeAssistantWarehouse.py
Outdated
Show resolved
Hide resolved
IoTuring/Warehouse/Deployments/HomeAssistantWarehouse/HomeAssistantWarehouse.py
Outdated
Show resolved
Hide resolved
The
So on HA it looks like ON-OFF-ON, not nice. The https://www.home-assistant.io/integrations/switch.mqtt/#optimistic So I recommend using the same KEY and topic for both the sensor and the command. Is there any bad side effect for this? Or the callback should also update the sensor automatically, but simply using the same key would be easier. |
I just added a really simple FileSwitch entity, it's easier to debug linked commands with this, you can see this "blinking" behavior, I'm speaking about, why I recommend having the same topic for state and command topic. |
Okay, got the problem. The reason I wanted to use a different key is because if the sensor data is sent as sensor (for non homeassistant warehouse), the key of the sensor may not define what the sensor value is, if equal to command key (maybe not in this case for monitor) |
So currently the solution I found is to send state value to command topic if it's linked to a command in the home assistant warehouse and do not use its key for the topic |
@infeeeee but if we send sensor state on command state we continue to call the command callback; I don't think it is a correct behavior. |
No solution found, I think we have to set different topics for sensor and command :( |
If you want to have different topics, other option would be to update the sensor after a callback. Not with the other sensors, but an extra update. Also still don't get why is it a problem, if they have the same topic. I get it's a problem, if the key is the same, but another solution could be in this case NOT use the key as the topic, but something else. Both MQTT and HA should let you use the same topic, it's only the KEY is the problem. That's 2 possible solutions |
The problem is not with the key, but with the message that the sensor sends to home assistant.
And the command triggered every 10 seconds is not a great thing in my opinion. What do you think ? |
I see. Maybe a check in the callback, to only run if the command state is not the same as the current state? Do nothing if it's the same. Or my other solution with different topics: send one out of loop update to the sensor, instantly, from the callback. I can't see a downside of this way. Maybe miss the next sensor update, in this case, so they won't run at the same time accidentally. |
With this commit, when a command is triggered from HA warehouse, if the command is a switch, also send the just received state to the topic of the sensor relative to the switch |
So with this edit we can use different topics for sensor and command in my opinion. What do you think ? Now I need to separate the two topics (sensor and command) which were re-joined |
I will take a look |
With these changes it seems solid |
I will check tomorrow, or later today, don't pull it yet |
Yes I would have waited for you anyway :) |
So I added some small fixes:
I tried to solve this, adding a new local variable If it's ok for you, you can pull it, I don't want to add any more changes. 🚀 |
Nice ! Yes I think it's time 🚀 |
Retrying #29