Skip to content

Commit

Permalink
fix topic of birth & last will message `homeassistant/{switchbot_mqtt…
Browse files Browse the repository at this point in the history
…->switchbot-mqtt}/status`

#106
  • Loading branch information
fphammerle committed Aug 31, 2022
2 parents 2dbcc13 + 9d8a18c commit 296d79b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Publish birth and last will message on expected/documented topic
`homeassistant/switchbot-mqtt/status` instead of topic
`homeassistant/switchbot_mqtt/status`.

## [3.3.0] - 2022-08-30
### Added
Expand Down
2 changes: 1 addition & 1 deletion switchbot_mqtt/__init__.py
Expand Up @@ -27,7 +27,7 @@

_LOGGER = logging.getLogger(__name__)

_MQTT_AVAILABILITY_TOPIC = "switchbot_mqtt/status"
_MQTT_AVAILABILITY_TOPIC = "switchbot-mqtt/status"
# "online" and "offline" to match home assistant's default settings
# https://www.home-assistant.io/integrations/switch.mqtt/#payload_available
_MQTT_BIRTH_PAYLOAD = "online"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mqtt.py
Expand Up @@ -66,7 +66,7 @@ def test__mqtt_on_connect(
0,
)
mqtt_client.publish.assert_called_once_with(
topic="whatever/switchbot_mqtt/status", payload="online", retain=True
topic="whatever/switchbot-mqtt/status", payload="online", retain=True
)
assert mqtt_client.subscribe.call_args_list == [
unittest.mock.call("whatever/switch/switchbot/+/set"),
Expand Down Expand Up @@ -142,7 +142,7 @@ def test__run(
assert not mqtt_client_mock().username_pw_set.called
mqtt_client_mock().tls_set.assert_called_once_with(ca_certs=None)
mqtt_client_mock().will_set.assert_called_once_with(
topic="homeassistant/switchbot_mqtt/status", payload="offline", retain=True
topic="homeassistant/switchbot-mqtt/status", payload="offline", retain=True
)
mqtt_client_mock().connect.assert_called_once_with(host=mqtt_host, port=mqtt_port)
mqtt_client_mock().socket().getpeername.return_value = (mqtt_host, mqtt_port)
Expand Down

0 comments on commit 296d79b

Please sign in to comment.