Reduce duplicate publish code in mqtt (#118163)

This commit is contained in:
J. Nick Koston 2024-05-26 01:22:54 -10:00 committed by GitHub
parent 5d37217d96
commit 80371d3a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 87 additions and 335 deletions

View file

@ -738,12 +738,8 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
self._attr_brightness = kwargs[ATTR_WHITE]
should_update = True
await self.async_publish(
str(self._topic[CONF_COMMAND_TOPIC]),
json_dumps(message),
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
await self.async_publish_with_config(
str(self._topic[CONF_COMMAND_TOPIC]), json_dumps(message)
)
if self._optimistic:
@ -763,12 +759,8 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
self._set_flash_and_transition(message, **kwargs)
await self.async_publish(
str(self._topic[CONF_COMMAND_TOPIC]),
json_dumps(message),
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
await self.async_publish_with_config(
str(self._topic[CONF_COMMAND_TOPIC]), json_dumps(message)
)
if self._optimistic: