Hi,
New to Home Assistant but I’m trying to get my home battery in the Energy dashboard.
Modified the configuration.yaml as following:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
Made a sensors.yaml file with the following:
template:
- sensor:
- name: Battery Charge Power
state_class: measurement
device_class: power
unit_of_measurement: W
state: >
{% if states('sensor.battery_power') | float(0) >= 0 %}
{% set gridout = (states('sensor.battery_power') |float |abs) %}
{% else %}
{% set gridout = 0 %}
{% endif %}
{{ gridout }}
availability: "{{ has_value('sensor.battery_power') }}"
- name: Battery Discharge Power
state_class: measurement
device_class: power
unit_of_measurement: W
state: >
{% if states('sensor.battery_power') | float(0) <= 0 %}
{% set gridout = (states('sensor.battery_power') |float |abs) %}
{% else %}
{% set gridout = 0 %}
{% endif %}
{{ gridout }}
availability: "{{ has_value('sensor.battery_power') }}"
When I try the code above in the developer tools → template it works.
If I restart HA I always get this message, and the sensors aren’t created:
ERROR (MainThread) [homeassistant.config] Invalid config for ‘sensor’ at configuration.yaml, line 12: required key ‘platform’ not provided, please check the docs at Sensor - Home Assistant
Help would be appreciated