Use _attr_force_update in mqtt (#77902)
parent
52c8c80f91
commit
f62fbbe524
|
@ -184,6 +184,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||
return DISCOVERY_SCHEMA
|
||||
|
||||
def _setup_from_config(self, config):
|
||||
self._attr_force_update = config[CONF_FORCE_UPDATE]
|
||||
self._value_template = MqttValueTemplate(
|
||||
self._config.get(CONF_VALUE_TEMPLATE),
|
||||
entity=self,
|
||||
|
@ -300,11 +301,6 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||
"""Return the class of this sensor."""
|
||||
return self._config.get(CONF_DEVICE_CLASS)
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
"""Force update."""
|
||||
return self._config[CONF_FORCE_UPDATE]
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return true if the device is available and value has not expired."""
|
||||
|
|
|
@ -233,6 +233,7 @@ class MqttSensor(MqttEntity, RestoreSensor):
|
|||
|
||||
def _setup_from_config(self, config):
|
||||
"""(Re)Setup the entity."""
|
||||
self._attr_force_update = config[CONF_FORCE_UPDATE]
|
||||
self._template = MqttValueTemplate(
|
||||
self._config.get(CONF_VALUE_TEMPLATE), entity=self
|
||||
).async_render_with_possible_json_value
|
||||
|
@ -350,11 +351,6 @@ class MqttSensor(MqttEntity, RestoreSensor):
|
|||
"""Return the unit this state is expressed in."""
|
||||
return self._config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
"""Force update."""
|
||||
return self._config[CONF_FORCE_UPDATE]
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the entity."""
|
||||
|
|
Loading…
Reference in New Issue