Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['sensors']['grid_power']['value_template']. Got "{{ (1000 * (states('sensor.whole_house_energy') | float - states.('sensor.solaredge_v2_power_meter') | float)) | int }}\n". (See /config/mqtt/sensors.yaml, line 41). Please check the docs at https://home-assistant.io/components/sensor.template/
Thrown back at me in the logs.
Its my understanding that once I have this plugged in then I can use this sensor in the cards configuration because this sensor “should” show if I’m pumping into the grid or consuming.
Lol sigh no not yet but thank you. I’ve actually been dealing with a bigger fish. My zwave got all messed up so I just got in the new stick for it today and I’ve been having “fun” adding all of my devices back in.
I think something broke a while back with my lovelace config because my dual thermostat stopped working but I have no idea what. I know I don’t have much in here and I hope that I have it formatted properly.
I have had some time to look at your code, and to be honest its beyond me I have the power wheel (no battery) working with
- platform: template
sensors:
solar_power:
friendly_name: 'Solar power production'
unit_of_measurement: 'kW'
value_template: >-
{{ (1000 * (states("sensor.fronius_current_production") | float)) | int }}
grid_power_sensor:
friendly_name: 'Grid power sensor'
unit_of_measurement: 'kW'
value_template: >-
{{ (1000 * (states("sensor.fronius_grid_usage") | float)) | int }}
and Lovelace as:
- type: 'custom:power-wheel-card'
title: House Power Flow
solar_power_entity: sensor.solar_power
grid_power_entity: sensor.grid_power_sensor
production_is_positive: false
I understand that I would have to delete the old template sensors I made above and create new ones,
and that you have changed the negative value of the grid sensor to a positive one, but I am lost on how your code would translate my existing solar and grid sensors?
e3dc_pv_batt_power_stat: <----- can I name this anything?
value_template: >
{% if states('sensor.fronius_current_production') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
sun
{% elif states('sensor.fronius_current_productionl') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
batt
{% elif states('sensor.fronius_current_production') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
sun_batt
{% else %}
sun
{% endif %}
Not sure what your ‘sensor.e3dc_battery_power’ is? What do I use here?
This is the template for the solar_power_entity i use. Remove the comments if you use it.
e3dc_pv_batt_power:
unit_of_measurement: 'W'
value_template: >
# Sun is shining and battery is charging
{% if states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
{{ states('sensor.e3dc_pv_total') }}
# Sun isn't shining and battery discharging
{% elif states('sensor.e3dc_pv_total') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
{{ (states('sensor.e3dc_battery_power') | int) | abs }}
# Sun is shining and battery discharging
{% elif states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
{{ states('sensor.e3dc_pv_total') | int + (states('sensor.e3dc_battery_power') | int) | abs }}
{% else %}
{{ states('sensor.e3dc_pv_total') }}
{% endif %}
BTW, now that i look at my config, this sensor template could be used for all 3 cards that i show with the state switch.
The only reason for the 3 cards was to have another icon for the solar_icon
Ok, thanks for all your help. Sadly, despite my best efforts, I am struggling with this one coming from a non-coding background. This is the first one that has beat me so far. I may look at this again later when I have a clearer head. Or who knows, might be lucky and have the a battery implemented in this power wheel card at some future date
@gurbyz Thanks, works great ! I now only need to find a way to get a Wh sensor for my grid usage. The SolarQuest has a sensor for solar production in Wh (“energy today”, “energy this month”, “energy this year”) but not for the grid sensor.
Would there be a way to create a custom sensor (template / history /…) that compute a grid energy Wh value based on some time rule and the grid_power_entity ?
Maybe I have to revise my first answer. Looking at your 3rd sensor, you write “how much I’m drawing (+) or injecting (-) from the grid, in kW” but I have to read / you have to add something to it. That is “as far as your solar panels know”. And the sensor of your solar panels doesn’t know e.g. what is consumed from the grid and directly going into your home.
To really see what you house is consuming and what you are consuming from the grid or delivering to the grid you need an extra sensor placed where the electricity is entering your house. Some people have a DSMR (a digital meter) that can be connected to HA. Other people use ‘clamps’ on certain electricity cables.
O, great, then your inverter indeed does know about grid consumption/production and the configuration for the power view is correct.
Maybe for the missing energy sensor (Wh), you can create something with a template sensor on top of a statistics sensor? Please note that for taking the most out of the power-wheel-card you have to create two Wh sensors for the grid: one for consuming from the grid and one for producing to the grid. (See also the readme file > requirements for energy view > point 4i and 4ii.)
An example to make that clear: let’s say you have one sensor and it has a value of +50 Wh. Then you don’t know if that’s the value because you produced 50 Wh to the grid and didn’t consume anything from the grid. If you have both sensors then they could have values of e.g. +250 Wh and -200 Wh and you know what happened exactly to get the nett result of +50 Wh.