
Hi, I'm after some help with home assistant and have seen a few users mention it before so I thought I'd ask here.
I have managed to get home assistant to pull from the Givenergy API using the code below. It's working, but I'm trying to get the battery in and battery out added to the built in energy view on home assistant. The problem is that these sensors don't appear in the list to choose from. I believe I need to add something to the config to declare them as long-term energy statistics. I thought that I needed to add:
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
However, when I validate the configuration.yaml it just says:
Invalid config for [sensor.template]: [state_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->out->state_class. (See ?, line ?).
Does anyone have any clue what I'm on about and have any ideas?
- platform: rest
name: plant data
json_attributes:
- soc
- dischargeEnergyToday
- chargeEnergyToday
resource: https://api.givenergy.cloud/plant/summary
scan_interval: 300
value_template: "{{ value_plant.data }}"
method: GET
headers:
Authorization: myapicodeisinhere - platform: template
sensors:
soc:
friendly_name: "SOC"
value_template: "{{ state_attr('sensor.plant_data', 'soc') }}"
out:
friendly_name: "Battery out today"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ state_attr('sensor.plant_data', 'dischargeEnergyToday') }}"
in:
friendly_name: "Battery in today"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
value_template: "{{ state_attr('sensor.plant_data', 'chargeEnergyToday') }}"