Add mqtt encoding support for publishing (#62739)

* encoding support for mqtt publishing - todo tests

* signature allows None values for qos and retain

* common test for mqtt publishing encoding

* better test with command templates

* more tests

* fix tests alarm control panel+tests light basic

* tests light json and template

* add tests vacuum and fix tests light_template
This commit is contained in:
Jan Bouwhuis 2022-01-03 09:03:47 +01:00 committed by GitHub
parent 2cc4d9846b
commit d0c4f0fec4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 1283 additions and 27 deletions

View file

@ -42,7 +42,14 @@ from homeassistant.util.percentage import (
from . import PLATFORMS, MqttCommandTemplate, subscription
from .. import mqtt
from .const import CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN, CONF_STATE_TOPIC, DOMAIN
from .const import (
CONF_COMMAND_TOPIC,
CONF_ENCODING,
CONF_QOS,
CONF_RETAIN,
CONF_STATE_TOPIC,
DOMAIN,
)
from .debug_info import log_messages
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
@ -542,6 +549,7 @@ class MqttFan(MqttEntity, FanEntity):
mqtt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if percentage:
await self.async_set_percentage(percentage)
@ -563,6 +571,7 @@ class MqttFan(MqttEntity, FanEntity):
mqtt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic:
self._state = False
@ -583,6 +592,7 @@ class MqttFan(MqttEntity, FanEntity):
mqtt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic_percentage:
@ -606,6 +616,7 @@ class MqttFan(MqttEntity, FanEntity):
mqtt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic_preset_mode:
@ -632,6 +643,7 @@ class MqttFan(MqttEntity, FanEntity):
mqtt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic_oscillation: