without the value_template, on the UI it is displaying status as
{"sensors": {"sensor": {"@name": "zooz dimmer a switch status", "#text": "off"}}}
trying to figue out how to extract just the status and display βoffβ and not the entire raw response
value:template does not seem to like β#β
error message is
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['sensors']['dinning_light_status']['value_template']. Got '{{sensor.["@name"] }}'. (See ?, line ?).
Invalid config for [sensor.rest]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['value_template']. Got '{{sensor.["#text"] }}'. (See ?, line ?).
Invalid config for [sensor.rest]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['value_template']. Got '{{sensor."#text" }}'. (See ?, line ?).
any ideas how to extract and display just the on / off value?
I have a follow up question regarding assigning custom value for display on UI. For my door lock, the value retured in βonβ for door locked and βoffβ for unlocked. currently on UI it displays on or off. How can i change this to display locked and unlocked. below is what i have tried so far (amongst many other things but this seems to get me closet but not quite:
platform: rest
name: Main Door Lock
resource: http://192.168.1.30:8688/controller/rest/devices/doorlock/status?name=doorlock_status
value_template: >
'{{value_json.sensors.sensor["#text"]}}'
'{% if is_state("sensor.main_door_lock", "on") %} locked {% else %} Unlocked {% endif %}'
output on the UI:
**Main Door Lock 'on' ' Unlocked ' `**
if i create an additional template sensor, the template sensor seems to display the values locked and unlocked correctly corresponding to on / off for the rest sensor. I am wondering if there is a way to do this without creating an additional template sensor
- platform: rest
name: Main Door Lock
resource: http://192.168.1.30:8688/controller/rest/devices/doorlock/status?name=doorlock_status
value_template: '{{value_json.sensors.sensor["#text"]}}'
- platform: template
sensors:
door_lock:
value_template: '{% if is_state("sensor.main_door_lock", "on") %} locked {% else %} Unlocked {% endif %}'
friendly_name: 'Main Door Lock'
Output on the UI for the 2 seperate sensors (Rest and template):