diff --git a/CHANGELOG.md b/CHANGELOG.md index 4568ee5..77847ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/switchbot_mqtt/__init__.py b/switchbot_mqtt/__init__.py index 34cd390..3f978b2 100644 --- a/switchbot_mqtt/__init__.py +++ b/switchbot_mqtt/__init__.py @@ -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" diff --git a/tests/test_mqtt.py b/tests/test_mqtt.py index 375ad9d..1b105be 100644 --- a/tests/test_mqtt.py +++ b/tests/test_mqtt.py @@ -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"), @@ -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)