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

_MQTT_AVAILABILITY_TOPIC_LEGACY does not work with will_set #106

Closed
phbasler opened this issue Aug 30, 2022 · 3 comments
Closed

_MQTT_AVAILABILITY_TOPIC_LEGACY does not work with will_set #106

phbasler opened this issue Aug 30, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@phbasler
Copy link
Contributor

Hi @fphammerle

I just saw the fix with MQTT_AVAILABILITY_TOPIC_LEGACY because of the "" to "-" mixup.

In

for topic in (_MQTT_AVAILABILITY_TOPIC, _MQTT_AVAILABILITY_TOPIC_LEGACY):
mqtt_client.will_set(
topic=mqtt_topic_prefix + topic,
payload=_MQTT_LAST_WILL_PAYLOAD,
retain=True,
)
you have the for loop which calls will_set twice. While this does not give you an error, it does not work as expected. If you call will_set, it overrides the old will. So in this case the Will is only for the _MQTT_AVAILABILITY_TOPIC_LEGACY and not for _MQTT_AVAILABILITY_TOPIC. You can only have one will in mqtt.

A possible workaround would be to have a second mqtt client which just has the will and the birth message to the legacy topic and have the original client have the non legacy topic.

But practically spoken: Why not declare it as a bug and make version 3.3.1 with the corrected topic?

@fphammerle fphammerle added the bug Something isn't working label Aug 31, 2022
fphammerle added a commit that referenced this issue Aug 31, 2022
…will on `homeassistant/switchbot_mqtt/status`)

partially reverts commit 9947875

#106 (comment)
#105
fphammerle added a commit that referenced this issue Aug 31, 2022
@fphammerle
Copy link
Owner

Thanks a lot, @phbasler, for following up and reviewing my changes!

After realizing that I had a mismatch between code and docs in v3.3.0, I was hoping that I could avoid a breaking change that way (but missed to check the docs or properly test the change).

I will follow your suggestion and call it a "fix" rather than a "change".

@fphammerle
Copy link
Owner

@phbasler
Copy link
Contributor Author

No problem, I'm just happy that it now works to have a template switch which can decide by itself if it should signal a satellite pi zero to control the switchbot or the server itself if the pi zero is not online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants