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:
parent
2cc4d9846b
commit
d0c4f0fec4
33 changed files with 1283 additions and 27 deletions
|
@ -42,7 +42,14 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||
|
||||
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
|
||||
|
||||
|
@ -547,6 +554,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
self._config[CONF_PAYLOAD_OPEN],
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._optimistic:
|
||||
# Optimistically assume that cover has changed state.
|
||||
|
@ -568,6 +576,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
self._config[CONF_PAYLOAD_CLOSE],
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._optimistic:
|
||||
# Optimistically assume that cover has changed state.
|
||||
|
@ -589,6 +598,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
self._config[CONF_PAYLOAD_STOP],
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
|
||||
async def async_open_cover_tilt(self, **kwargs):
|
||||
|
@ -599,6 +609,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
self._config[CONF_TILT_OPEN_POSITION],
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
self._tilt_value = self.find_percentage_in_range(
|
||||
|
@ -614,6 +625,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
self._config[CONF_TILT_CLOSED_POSITION],
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
self._tilt_value = self.find_percentage_in_range(
|
||||
|
@ -643,6 +655,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
tilt,
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
_LOGGER.debug("Set tilt value optimistic")
|
||||
|
@ -670,6 +683,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
position,
|
||||
self._config[CONF_QOS],
|
||||
self._config[CONF_RETAIN],
|
||||
self._config[CONF_ENCODING],
|
||||
)
|
||||
if self._optimistic:
|
||||
self._state = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue