Filter MQTT sensor JSON attributes (#52289)
This commit is contained in:
parent
e0f7987544
commit
61f7f5c96a
2 changed files with 10 additions and 1 deletions
|
@ -44,6 +44,13 @@ CONF_LAST_RESET_TOPIC = "last_reset_topic"
|
|||
CONF_LAST_RESET_VALUE_TEMPLATE = "last_reset_value_template"
|
||||
CONF_STATE_CLASS = "state_class"
|
||||
|
||||
MQTT_SENSOR_ATTRIBUTES_BLOCKED = frozenset(
|
||||
{
|
||||
sensor.ATTR_LAST_RESET,
|
||||
sensor.ATTR_STATE_CLASS,
|
||||
}
|
||||
)
|
||||
|
||||
DEFAULT_NAME = "MQTT Sensor"
|
||||
DEFAULT_FORCE_UPDATE = False
|
||||
PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend(
|
||||
|
@ -87,6 +94,7 @@ class MqttSensor(MqttEntity, SensorEntity):
|
|||
"""Representation of a sensor that can be updated using MQTT."""
|
||||
|
||||
_attr_last_reset = None
|
||||
_attributes_extra_blocked = MQTT_SENSOR_ATTRIBUTES_BLOCKED
|
||||
|
||||
def __init__(self, hass, config, config_entry, discovery_data):
|
||||
"""Initialize the sensor."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue