Need testers for updated Enphase Envoy sensor

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?

@cjsimmons Thank you!

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. :crossed_fingers:

1 Like

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.

Sorry for such a rookie question…but I’m a rookie…where do I paste this code? I’d much rather read my envoy data in kW. Thank you.

@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.

1 Like

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?

Oh no. No this is in addition. What you are doing is creating another sensor using a template.

If your configuration.yaml file does not have a sensor: section you can paste it at the bottom of your file.

If you do have a sensor: section than you’ll have to paste in that area omitting sensor: as your file already has it

Just tried it…this is what happens when I check the yaml:
image

Here’s my whole yaml file:


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

#sensors
sensor:
  - platform: enphase_envoy
    ip_address: 192.168.86.187
    monitored_conditions:
      - production
      - daily_production
      - consumption
      - daily_consumption
  - platform: template
      sensors:
        envoy_current_energy_production_kw:
          friendly_name_template: 'Envoy Current Energy Production (kW)'
          unit_of_measurement: 'kW'
          value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }} "

I think the spacing is a bit off, sensors and the rest below looks to be indented a few spaces too much. Should be like this

  - platform: template
    sensors:
      envoy_current_energy_production_kw:
        friendly_name_template: 'Envoy Current Energy Production (kW)'
        unit_of_measurement: 'kW'
        value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }}"

EDIT: My original post had spacing issues too. Fixed now!

It worked! And now I’ve learned spacing is important! Thank you.

I’d love to use this! Where do I copy and paste this code? I’m a noob to HA and Lovelace. Thank you for your help.

Hi there,

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:

Have a go and then come back with any questions…


Thank you very much!
I now have 3 more questions! :upside_down_face:

  1. 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.
  2. I’d like to make that “Net Energy Value” either red or green based on if it’s positive or negative value
  3. 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) }}"

Thank you all for your help!

Hi there,

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:

1 Like

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!

Hi Rob,
@robschwandt

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).

Thank you :blush:

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.

1 Like

Hi @dgaust

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:

Configuration invalid!
Package solar_production_difference setup failed. Component inst_energy_difference Integration ‘inst_energy_difference’ not found.

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) }}
1 Like

Hi again @dgaust

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?