Fix Command Line template error when data is None (#97845)

Command Line template error
This commit is contained in:
G Johansson
2023-08-05 16:21:39 +02:00
committed by GitHub
parent c5e5567912
commit 2e263560ec
2 changed files with 41 additions and 3 deletions

View File

@@ -207,7 +207,8 @@ class CommandSensor(ManualTriggerEntity, SensorEntity):
self._process_manual_data(value)
return
if self._value_template is not None:
self._attr_native_value = None
if self._value_template is not None and value is not None:
value = self._value_template.async_render_with_possible_json_value(
value,
None,
@@ -221,7 +222,6 @@ class CommandSensor(ManualTriggerEntity, SensorEntity):
self._process_manual_data(value)
return
self._attr_native_value = None
if value is not None:
self._attr_native_value = async_parse_date_datetime(
value, self.entity_id, self.device_class