Hi All
I have an efergy monitoring system with which I am monitoring my Solar generation and my house power usage. I have been trying to get the new energy dash to working HA.
I have created a few template sensors to allow me to configure it. As my Efergy sensors are only reporting in Watt.
So with integration I can get a sensor to give me kwh, which I done as this
- platform: integration
source: sensor.efergy_house
name: energy_used
unit_prefix: k
round: 2
- platform: integration
source: sensor.efergy_solar
name: energy_generated
unit_prefix: k
round: 2
I then created a sensor to tell me what I draw from the grid by doing “sensor.efergy_solar - sensor.efergy_house” Which I dont think is work as I expected, cause the dashboard is show me negative during the night when I am not generating anything.
power_from_grid_kwh:
friendly_name: "Power From Grid KwH"
unit_of_measurement: 'kWh'
value_template: >-
{% set puse =states('sensor.energy_used') | float %}
{% set pgen =states('sensor.energy_generated') | float %}
{% if states('sensor.efergy_solar') | int > 50 %}0{% else %}
{{ puse - pgen}}
{% endif %}
device_class: energy
My solar inverter also show a draw of 45W when its not generating anything. This also now shows as I am generating power at night when I am actually drawing power.
So I have a few questions,
- How can I get my Solar sensor to show “0” when the reading is below 50W? I tried this but it keeps giving me errors.
- platform: template
sensors:
energy_generated_true:
friendly_name: "Real Energy Generated"
unit_of_measurement: 'W'
value_template: '{% if states('sensor.efergy_562129') | int < 50 %}0{% else %}{{ state_attr("sensor.efergy_562129", "energy_generated_true") }}{% endif %}'
device_class: energy
- The Sensors I need to add to the Energy config is not making sense to me.
I have my “Power From Grid KwH” sensor above configured as my Grid consumption
power_from_grid_kwh:
friendly_name: "Power From Grid KwH"
unit_of_measurement: 'kWh'
value_template: >-
{% set puse =states('sensor.energy_used') | float %}
{% set pgen =states('sensor.energy_generated') | float %}
{% if states('sensor.efergy_solar') | int > 50 %}0{% else %}
{{ puse - pgen}}
{% endif %}
device_class: energy
I have a “Excess Power KhW” as my Return to grid
excess_power_kwh:
friendly_name: "Excess Power KwH"
unit_of_measurement: 'kWh'
value_template: >-
{% set puse =states('sensor.energy_used') | float %}
{% set pgen =states('sensor.energy_generated') | float %}
{% if states('sensor.efergy_562129') | int < 50 %}0{% else %}
{{ pgen - puse}}
{% endif %}
device_class: energy
I have my “energy_generated” on my Solar Panels
- platform: integration
source: sensor.efergy_solar
name: energy_generated
unit_prefix: k
round: 2
Then “energy_used” under my individual devices
- platform: integration
source: sensor.efergy_house
name: energy_used
unit_prefix: k
round: 2
This is how my dashboard looks after a day
My sensor.yaml
- platform: efergy
app_token: MYAPI-KEY
utc_offset: 720
monitored_variables:
- type: current_values
- type: instant_readings
- platform: pvoutput
system_id: 12345
api_key: MYKEY
scan_interval: 120
- platform: template
sensors:
power_consumption:
value_template: '{% if is_state_attr("sensor.pvoutput", "power_consumption", "NaN") %}0{% else %}{{ state_attr("sensor.pvoutput", "power_consumption") }}{% endif %}'
friendly_name: 'Using'
unit_of_measurement: 'Watt'
device_class: energy
energy_consumption:
value_template: '{{ "%0.1f"|format(state_attr("sensor.pvoutput", "energy_consumption")|float/1000) }}'
friendly_name: 'Used'
unit_of_measurement: 'kWh'
device_class: energy
power_generation:
value_template: '{% if is_state_attr("sensor.pvoutput", "power_generation", "NaN") %}0{% else %}{{ state_attr("sensor.pvoutput", "power_generation") }}{% endif %}'
friendly_name: 'Generating'
unit_of_measurement: 'Watt'
device_class: energy
energy_generation:
value_template: '{% if is_state_attr("sensor.pvoutput", "energy_generation", "NaN") %}0{% else %}{{ "%0.2f"|format(state_attr("sensor.pvoutput", "energy_generation")|float/1000) }}{% endif %}'
friendly_name: 'Generated'
unit_of_measurement: 'kWh'
device_class: energy
# Use for Device Automation
power_generation2:
friendly_name: "Excess Power"
unit_of_measurement: 'Watt'
device_class: energy
value_template: >-
{% set t = states('sensor.efergy_house') | float %}
{% set u = states('sensor.efergy_solar') | float %}
{% if states('sensor.efergy_solar') | int < 400 %}0{% else %}
{{ u - t}}
{% endif %}
power_from_grid_kwh:
friendly_name: "Power From Grid KwH"
unit_of_measurement: 'kWh'
value_template: >-
{% set puse =states('sensor.energy_used') | float %}
{% set pgen =states('sensor.energy_generated') | float %}
{% if states('sensor.efergy_solar') | int > 50 %}0{% else %}
{{ puse - pgen}}
{% endif %}
device_class: energy
excess_power_kwh:
friendly_name: "Excess Power KwH"
unit_of_measurement: 'kWh'
value_template: >-
{% set puse =states('sensor.energy_used') | float %}
{% set pgen =states('sensor.energy_generated') | float %}
{% if states('sensor.efergy_solar') | int < 50 %}0{% else %}
{{ pgen - puse}}
{% endif %}
device_class: energy
energy_generated_true:
friendly_name: "Real Energy Generated"
unit_of_measurement: 'W'
value_template: '{% if states('sensor.efergy_solar') | int < 50 %}0{% else %}{{ state_attr("sensor.efergy_solar", "energy_generated_true") }}{% endif %}'
device_class: energy
- platform: integration
source: sensor.efergy_house
name: energy_used
unit_prefix: k
round: 2
- platform: integration
source: sensor.efergy_solar
name: energy_generated
unit_prefix: k
round: 2
# PI Temps Sensore
- platform: command_line
name: CPU Temperature
command: "cat /sys/class/thermal/thermal_zone0/temp"
# If errors occur, make sure configuration file is encoded as UTF-8
unit_of_measurement: "°C"
value_template: "{{ value | multiply(0.001) | round(1) }}"
Any help would be much appreciated.
Thanks
CVR