Hi all,
I have a scrape sensor, but the website goes offline time by time (long story). When this happends, the sensor throws an error:
WARNING (MainThread) [homeassistant.components.scrape.sensor] Index '0' not found in sensor.scrape_test
How do I use value_template
to counter this effect?
The sensor:
- resource_template: "website"
scan_interval: 60
timeout: 60
sensor:
- name: "scrape test"
icon: mdi:airplane
select: ".value_class"
index: 0
value_template: |
{% if value[0] is none %}
"unknown"
{% else %}
{{ value }}
{% endif %}
I tried:
{{ value is not none }}
{{ value is defined }}
{{ value is null }}
cheers!