Add mqtt sensor configurable state encoding for sensor and binary_sensor platform (#60447)
* Add mqtt sensor state encoding * Make encoding attribute not specific to states * Move encoding attribute to schema base
This commit is contained in:
parent
7469f083fd
commit
2a2a20fcb3
8 changed files with 76 additions and 7 deletions
|
@ -28,7 +28,7 @@ from homeassistant.util import dt as dt_util
|
|||
|
||||
from . import PLATFORMS, subscription
|
||||
from .. import mqtt
|
||||
from .const import CONF_QOS, CONF_STATE_TOPIC, DOMAIN
|
||||
from .const import CONF_ENCODING, CONF_QOS, CONF_STATE_TOPIC, DOMAIN
|
||||
from .debug_info import log_messages
|
||||
from .mixins import (
|
||||
MQTT_ENTITY_COMMON_SCHEMA,
|
||||
|
@ -200,6 +200,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity):
|
|||
"topic": self._config[CONF_STATE_TOPIC],
|
||||
"msg_callback": state_message_received,
|
||||
"qos": self._config[CONF_QOS],
|
||||
"encoding": self._config[CONF_ENCODING] or None,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue