diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index dac6527b268..a0527cfe427 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -714,11 +714,10 @@ class MQTT: if will_message is not None: self._mqttc.will_set( # pylint: disable=no-value-for-parameter - *attr.astuple( - will_message, - filter=lambda attr, value: attr.name - not in ["subscribed_topic", "timestamp"], - ) + topic=will_message.topic, + payload=will_message.payload, + qos=will_message.qos, + retain=will_message.retain, ) async def async_publish( @@ -865,11 +864,10 @@ class MQTT: birth_message = Message(**self.conf[CONF_BIRTH_MESSAGE]) self.hass.add_job( self.async_publish( # pylint: disable=no-value-for-parameter - *attr.astuple( - birth_message, - filter=lambda attr, value: attr.name - not in ["subscribed_topic", "timestamp"], - ) + topic=birth_message.topic, + payload=birth_message.payload, + qos=birth_message.qos, + retain=birth_message.retain, ) ) diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index a6eb7e46f59..15d92b9a311 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -799,13 +799,15 @@ async def test_no_birth_message(hass, mqtt_client_mock, mqtt_mock): ) async def test_custom_will_message(hass, mqtt_client_mock, mqtt_mock): """Test will message.""" - mqtt_client_mock.will_set.assert_called_with("death", "death", 0, False) + mqtt_client_mock.will_set.assert_called_with( + topic="death", payload="death", qos=0, retain=False + ) async def test_default_will_message(hass, mqtt_client_mock, mqtt_mock): """Test will message.""" mqtt_client_mock.will_set.assert_called_with( - "homeassistant/status", "offline", 0, False + topic="homeassistant/status", payload="offline", qos=0, retain=False )