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:
Jan Bouwhuis 2021-11-30 14:04:24 +01:00 committed by GitHub
parent 7469f083fd
commit 2a2a20fcb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 7 deletions

View file

@ -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,
}
},
)