mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
Use _attr_force_update in mqtt (#77902)
This commit is contained in:
parent
52c8c80f91
commit
f62fbbe524
@ -184,6 +184,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||||||
return DISCOVERY_SCHEMA
|
return DISCOVERY_SCHEMA
|
||||||
|
|
||||||
def _setup_from_config(self, config):
|
def _setup_from_config(self, config):
|
||||||
|
self._attr_force_update = config[CONF_FORCE_UPDATE]
|
||||||
self._value_template = MqttValueTemplate(
|
self._value_template = MqttValueTemplate(
|
||||||
self._config.get(CONF_VALUE_TEMPLATE),
|
self._config.get(CONF_VALUE_TEMPLATE),
|
||||||
entity=self,
|
entity=self,
|
||||||
@ -300,11 +301,6 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return self._config.get(CONF_DEVICE_CLASS)
|
return self._config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
@property
|
|
||||||
def force_update(self) -> bool:
|
|
||||||
"""Force update."""
|
|
||||||
return self._config[CONF_FORCE_UPDATE]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return true if the device is available and value has not expired."""
|
"""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):
|
def _setup_from_config(self, config):
|
||||||
"""(Re)Setup the entity."""
|
"""(Re)Setup the entity."""
|
||||||
|
self._attr_force_update = config[CONF_FORCE_UPDATE]
|
||||||
self._template = MqttValueTemplate(
|
self._template = MqttValueTemplate(
|
||||||
self._config.get(CONF_VALUE_TEMPLATE), entity=self
|
self._config.get(CONF_VALUE_TEMPLATE), entity=self
|
||||||
).async_render_with_possible_json_value
|
).async_render_with_possible_json_value
|
||||||
@ -350,11 +351,6 @@ class MqttSensor(MqttEntity, RestoreSensor):
|
|||||||
"""Return the unit this state is expressed in."""
|
"""Return the unit this state is expressed in."""
|
||||||
return self._config.get(CONF_UNIT_OF_MEASUREMENT)
|
return self._config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||||
|
|
||||||
@property
|
|
||||||
def force_update(self) -> bool:
|
|
||||||
"""Force update."""
|
|
||||||
return self._config[CONF_FORCE_UPDATE]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user