I am using the Enphase sensor to monitor my solar production and consumption.
I need a ‘power produced’ - ‘power consumed’ sensor in order to control high power devices based on grid export/import.
Invalid config for [sensor.template]: expected a dictionary for dictionary value @ data[‘sensors’][‘friendly_name’]. Got ‘“Net Power”’
expected a dictionary for dictionary value @ data[‘sensors’][‘netpowercalc’]. Got None
expected a dictionary for dictionary value @ data[‘sensors’][‘value_template’]. Got ‘{{(states.sensor.envoy_current_energy_production.state | float ) - (states.sensor.envoy_current_energy_consumption.state | float)}}’. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Here is the updated code which also removes the decimal point
template:
- sensor:
- name: Net Power
state_class: measurement
unit_of_measurement: W
device_class: power
icon: mdi:transmission-tower
state: >
{% set production = states.sensor.envoy_SERIALNUMBER_current_energy_production.state | int %}
{% set consumption = states.sensor.envoy_SERIALNUMBER_current_energy_consumption.state | int %}
{{ (production - consumption) }}
template:
- sensor:
- name: Net Power
state_class: measurement
unit_of_measurement: W
device_class: power
icon: mdi:transmission-tower
state: >
{% set production = states('sensor.envoy_SERIALNUMBER_current_power_production') | int %}
{% set consumption = states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int %}
{{ (production - consumption) }}
This is slightly off topic but I added a notification to notify me when net power goes above or below 0 and then show what the current value of the sensor is.
alias: Notifty when Positive
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.net_power
above: '0'
condition: []
action:
- service: notify.notify
data_template:
message: Positive Net Power {{ states('sensor.net_power') }} Watts
mode: single