Just installed this. Awesome work. I’ve been wanting to get my inverter data into HA for a while now, but haven’t been bothered to do anything about it. I’m currently using REST sensors to get the data on production, total consumption, and net consumption.
I noticed some chat above about the net consumption data. So, this is being worked on, and will be available when it’s merged for the next release?
The next step is to migrate from the configuration.yaml to Configuration Flow UI configuration. Once that is done than adding new sensors such as net consumption, 3phase info, battery info, etc… shouldn’t be too hard as long as the data is available from the Envoy device.
I was hoping to have something for the Configuration Flow by next weekend.
No worries. Keep up the good work. Good to see someone updating the Enphase intergration. I haven’t ever used it and just used REST sensors. Your update seems to be doing a good job over the last few hours.
@robschwandt No problem! Paste the code into your configuration.yaml. Then from Home Assistant >> Configuration >> Server Controls click on the button to make sure your yaml file is valid. Than restart the server and you’ll have a sensor with kW.
So I have the standard code from the home assistant page for envoy(ip address and the variables I want to track). So delete all that and paste this instead?
Maybe start by reading the opening thread, it is possible to get everything working from there. Once you copy the code in to your configuration.yaml file and have installed the Enphase integration it will work.
I really set up a new page on my dab board and then added the inverters and other Enphase data as per the below:
I’d like to add a “Net Energy Value” as an entity in my lovelace card. I tried writing my own yaml math, but it’s not working. YAML attached.
I’d like to make that “Net Energy Value” either red or green based on if it’s positive or negative value
I’d like to use the gauge card for my “Net Energy Value” that sits in the middle of the gauge to represent 0, move left and make it red for negative values, move right and green for a positive number.
- platform: template
sensors:
envoy_current_energy_production_kw:
friendly_name_template: 'Envoy Current Energy Production (kW)'
unit_of_measurement: 'kW'
icon_template: mdi:lightning-bolt
value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }}"
envoy_current_energy_consumption_kw:
friendly_name_template: 'Envoy Current Energy Consumption (kW)'
unit_of_measurement: 'kW'
icon_template: mdi:battery-medium
value_template: "{{ (states('sensor.envoy_current_energy_consumption')| float / 1000| round(2)) }}"
envoy_today_s_energy_production_kw:
friendly_name_template: 'Envoy All Day Energy Production (kW)'
unit_of_measurement: 'kW'
icon_template: mdi:lightning-bolt-outline
value_template: "{{ (states('sensor.envoy_today_s_energy_production')| float / 1000| round(2)) }}"
envoy_today_s_energy_consumption_kw:
friendly_name_template: 'Envoy All Day Energy Consumption (kW)'
unit_of_measurement: 'kW'
icon_template: mdi:battery-medium
value_template: "{{ (states('sensor.envoy_today_s_energy_consumption')| float / 1000| round(2)) }}"
envoy_net_energy_value_kw:
friendly_name_template: 'Envoy Net Energy Value (kW)'
unit_of_measurement: 'kW'
icon_template: mdi:battery-heart-variant
value_template: "{{ (states('envoy_today_s_energy_production_kw') - states('envoy_today_s_energy_consumption_kw')| float / 1000)| round(2) }}"
I’m new to HA too so I can’t help with the coding and any non standard dashboard cards…but I can help with the icon:
icon_template: hass:flash
It will be interesting to see the code required for the “swing o meter”
If you select a gauge card from the dash board editor then set a minus number range up to 0 you can choose the green, then for 0 to xxxx you can choose either yellow our red range. See below:
I just needed you all to believe in me! I figured it out thanks to all the work and time you all spend documenting your progress on these forums. Thank you again for all of your help!
Please can you share your solution. I would like to learn about the coding, as I want to set up some logical script to switch on and off my electric underfloor heating when my solar production is at certain higher points than my house base load (Production > Load).
The difference in production/consumption can be done in a template sensor like this
inst_energy_difference:
friendly_name: Instant Energy Difference
icon_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
mdi:solar-panel
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
mdi:transmission-tower
{%- else -%}
mdi:power-off
{%- endif %}
friendly_name_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
Currently Exporting
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
Currently Importing
{%- else -%}
Balanced
{%- endif %}
unit_of_measurement: "W"
device_class: power
value_template: >
{{ '%0.1f' | format(states('sensor.solarenvoy_current_energy_production') | float - states('sensor.solarenvoy_current_energy_consumption') | float) }}
It will then provide a sensor that you can use to display like this (the bottom card, which is converted to kW by the lovelace card, the sensor value is in watts just to be more accurate), or in automations as a trigger.
Thank you for the assistance. I tried since this morning to get this to work. I have areay created a packages folder and so I created a new .yaml file in there with your code. After several editing attempts I nerly got it to parse the configuration check but still getting stuck on the following error message:
Here is my (your) code that i created in a new file: /config/packages/solar_production_difference.yaml
# Solar Net Meter
inst_energy_difference:
friendly_name: Instant Energy Difference
icon_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
mdi:solar-panel
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
mdi:transmission-tower
{%- else -%}
mdi:power-off
{%- endif %}
friendly_name_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
Currently Exporting
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
Currently Importing
{%- else -%}
Balanced
{%- endif %}
unit_of_measurement: "W"
device_class: power
value_template: >
{{ '%0.1f' | format(states('sensor.hauxtonenvoy_current_energy_production') | float - states('sensor.hauxtonenvoy_current_energy_consumption') | float) }}
Any assistance would be great. my problem is that I don’t understand the coding very well. and here everything seems to be important even like the spaces before a line lol! Also i dont see the Card in the overview nor the entity “inst_energy_difference”
Sorry, I should have been clearer (as I was just posting under other template sensor posts). It’s not a component itself, but a template sensor so it would look more like
sensor:
- platform: template
sensors:
inst_energy_difference:
friendly_name: Instant Energy Difference
icon_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
mdi:solar-panel
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
mdi:transmission-tower
{%- else -%}
mdi:power-off
{%- endif %}
friendly_name_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
Currently Exporting
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
Currently Importing
{%- else -%}
Balanced
{%- endif %}
unit_of_measurement: "W"
device_class: power
value_template: >
{{ '%0.1f' | format(states('sensor.hauxtonenvoy_current_energy_production') | float - states('sensor.hauxtonenvoy_current_energy_consumption') | float) }}
Thank you once again for corrections. I have tried to get this to work for the entire weekend but still hitting problems. In the editor I got the green tick showing the coding is correct (?) after a lot of learning about indentations! However when I try to parse the file in the configuration checker it fails with the message “Invalid config for [sensor.template]: [inst_energy_difference] is an invalid option for [sensor.template]. Check: sensor.template->inst_energy_difference. (See ?, line ?).”
Here is my .yaml file please could you check it over and let me know where I’m going wrong.
sensor:
- platform: template
inst_energy_difference:
friendly_name: Instant Energy Difference
icon_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
mdi:solar-panel
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
mdi:transmission-tower
{%- else -%}
mdi:power-off
{%- endif %}
friendly_name_template: >
{% if (states("sensor.inst_energy_difference") | int > 0) -%}
Currently Exporting
{%- elif (states("sensor.inst_energy_difference") | int < 0) -%}
Currently Importing
{%- else -%}
Balanced
{%- endif %}
unit_of_measurement: "W"
device_class: power
value_template: >
{{ '%0.1f' | format(states('sensor.hauxtonenvoy_current_energy_production') | float - states('sensor.hauxtonenvoy_current_energy_consumption') | float) }}
Do I have to define the sensor " inst_energy_difference: " somewhere else within HA?