I already transformed my sensors from the sensor.yaml to templates.yaml, but I don’t know what to do with these :
- platform: template
sensors:
battery_alert:
value_template: >
{% set ns = namespace(below=[]) %}
{% for s in states.sensor %}
{% if s.entity_id.endswith('_power') and s.state != 'unknown' and s.state|int(0) < 20 %}
{% set ns.below = ns.below + [ s ] %}
{% endif %}
{% if s.entity_id.endswith('_pathlight') and s.entity_id.startswith('sensor.nest_protect_') and s.state != 'Medium' %}
{% set ns.below = ns.below + [ s ] %}
{% endif %}
{% endfor %}
{{ ns.below | count }}
attribute_templates:
battery_low: >
{% set ns = namespace(below=[]) %}
{% for s in states.sensor %}
{% if '_power' in s.entity_id and s.state != 'unknown' and s.state|int(0) < 20 %}
{% set ns.below = ns.below + [ s.name[:-6] ~ ' (' ~ s.state ~ '%)'] %}
{% endif %}
{% if s.entity_id.endswith('_pathlight') and s.entity_id.startswith('sensor.nest_protect_') and s.state != 'Medium' %}
{% set ns.below = ns.below + [ s.name[:-10] ~ ' (' ~ s.state ~ ')'] %}
{% endif %}
{% endfor %}
{{ ns.below | join(', ') }}
- platform: systemmonitor
resources:
- type: processor_use
- type: processor_temperature
- type: memory_free
- type: disk_use_percent
arg: /
- type: disk_use
- type: disk_free
- type: throughput_network_in
arg: eth0
- type: throughput_network_out
arg: eth0
- platform: command_line
command: !secret URL_sensor_camera_living
name: "Motion Camera Living"
value_template: >
{% set status = value | regex_findall_index('Alarm>(\d+)</motion') %}
{% set values = {'0':'Disabled', '1':'Enabled', '2':'Detected'} %}
{{ values[status] if status in values.keys() else 'Not Determined'}}
scan_interval: 5
Can somebody help me please ?