I’ve setup an ESP32 with ESPRESENSE.
I’ve added it to MQTT
Now when i try to add the YAML i get an error, so i might be doing something wrong.
I hade split-up my configuration.yaml so i have a seperate sensors.yaml
This give’s me the above error when restarting Home Assistant
Error: Invalid config for ‘sensor’ from integration ‘mqtt_room’ at sensors.yaml, line 96: required key ‘device_id’ not provided
## Voor het batterij icoon in de person template van Maurice ##
- platform: template
sensors:
iphone_van_maurice_battery_icon:
friendly_name: "iPhone van Maurice Battery Icon"
value_template: >
{% set state = states('sensor.iphone_van_maurice_battery_level')|float %}
{% if state >= 0 and state < 10 %} mdi:battery-10
{% elif state >= 10 and state < 20 %} mdi:battery-20
{% elif state >= 20 and state < 30 %} mdi:battery-30
{% elif state >= 30 and state < 40 %} mdi:battery-40
{% elif state >= 40 and state < 50 %} mdi:battery-50
{% elif state >= 50 and state < 60 %} mdi:battery-60
{% elif state >= 60 and state < 70 %} mdi:battery-70
{% elif state >= 70 and state < 80 %} mdi:battery-80
{% elif state >= 80 and state < 95 %} mdi:battery-90
{% else %} mdi:battery
{% endif %}
- platform: template
sensors:
iphone_van_maurice_battery_color:
friendly_name: "iPhone van Maurice Battery Color"
value_template: >
{% set state = states('sensor.iphone_van_maurice_battery_level')|float %}
{% if state >= 0 and state < 20 %} red
{% elif state >= 20 and state < 50 %} orange
{% elif state >= 50 and state < 70 %} yellow
{% else %} green
{% endif %}
## Voor het batterij icoon in de person template van Yvette ##
- platform: template
sensors:
iphone_van_yvette_battery_icon:
friendly_name: "iPhone van Yvette Battery Icon"
value_template: >
{% set state = states('sensor.iphone_van_maurice_battery_level')|float %}
{% if state >= 0 and state < 10 %} mdi:battery-10
{% elif state >= 10 and state < 20 %} mdi:battery-20
{% elif state >= 20 and state < 30 %} mdi:battery-30
{% elif state >= 30 and state < 40 %} mdi:battery-40
{% elif state >= 40 and state < 50 %} mdi:battery-50
{% elif state >= 50 and state < 60 %} mdi:battery-60
{% elif state >= 60 and state < 70 %} mdi:battery-70
{% elif state >= 70 and state < 80 %} mdi:battery-80
{% elif state >= 80 and state < 95 %} mdi:battery-90
{% else %} mdi:battery
{% endif %}
- platform: template
sensors:
iphone_van_yvette_battery_color:
friendly_name: "iPhone van Yvette Battery Color"
value_template: >
{% set state = states('sensor.iphone_van_maurice_battery_level')|float %}
{% if state >= 0 and state < 20 %} red
{% elif state >= 20 and state < 50 %} orange
{% elif state >= 50 and state < 70 %} yellow
{% else %} green
{% endif %}
## SolarEdge Templates ##
- platform: template
sensors:
solaredge_energy_this_year_template:
value_template: "{{ (states('sensor.solaredge_energy_this_year') | float / 1000) | round(0) }}"
unit_of_measurement: "kWh"
solaredge_current_power_template:
value_template: "{{ (states('sensor.solaredge_current_power') | float / 1000) | round(2) }}"
unit_of_measurement: "kW"
solaredge_energy_today_template:
value_template: "{{ (states('sensor.solaredge_energy_today') | float / 1000) | round(2) }}"
unit_of_measurement: "kWh"
solaredge_lifetime_energy_template:
value_template: "{{ (states('sensor.solaredge_lifetime_energy') | float / 1000) | round(2) }}"
unit_of_measurement: "kWh"
# Total Lights On
- platform: template
sensors:
total_lights:
unique_id: total_light
friendly_name: "Total Lights On"
value_template: >-
{{ states.light
|selectattr('state','eq','on')
|rejectattr('attributes.entity_id','defined')
|list |count }}
attribute_templates:
light_entities: >-
{% set domain = 'light' %}
{% set entities = states[domain] | selectattr('state','eq','on') | map(attribute='entity_id') | list %}
{%- for s in entities -%}
- {{ s }},
{%- endfor %}