Make variable entity_id available to value_template for MQTT binary sensor (#19195)
* MQTT binary_sensor: Make variable `entity_id` available to value_template * Review comments * Add testcase
This commit is contained in:
1 parent
e886576a64
commit
b97f0c0261
3 files changed
+33
-5
No files matched your search
@@ -135,7 +135,7 @@ class MqttBinarySensor(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
||||
value_template = self._config.get(CONF_VALUE_TEMPLATE)
|
||||
if value_template is not None:
|
||||
payload = value_template.async_render_with_possible_json_value(
|
||||
payload)
|
||||
payload, variables={'entity_id': self.entity_id})
|
||||
if payload == self._config.get(CONF_PAYLOAD_ON):
|
||||
self._state = True
|
||||
elif payload == self._config.get(CONF_PAYLOAD_OFF):
|
||||
|
||||
Reference in new issue
Block a user