Use keywords for MQTT birth and will (#38040)
parent
908b72370b
commit
fa0e12ffe8
|
@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue