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

@ -59,7 +59,13 @@ import homeassistant.util.color as color_util
from .. import subscription
from ... import mqtt
from ..const import CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN, CONF_STATE_TOPIC
from ..const import (
CONF_COMMAND_TOPIC,
CONF_ENCODING,
CONF_QOS,
CONF_RETAIN,
CONF_STATE_TOPIC,
)
from ..debug_info import log_messages
from ..mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity
from .schema import MQTT_LIGHT_SCHEMA_SCHEMA
@ -629,6 +635,7 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
json.dumps(message),
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic:
@ -654,6 +661,7 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
json.dumps(message),
self._config[CONF_QOS],
self._config[CONF_RETAIN],
self._config[CONF_ENCODING],
)
if self._optimistic: