MYPV integration started

Thanks @zauberertz for your work on integrating the mypv elwa-e system into the homeassistant.

I can now read every metric except for power. The identity is displayed but it does not contain a value.
Have I configured something incorrectly here, or is this a bug?

Hi everyone,

let me contribute my findings to integrate the MY-PV WiFi Meter. Reference to product: my-PV

The MY-PV WiFi smart meter can be accessed via modbus. Therefor you need to do the following:

  1. Add modbus: !include modbus.yaml to your configutation.yaml
  2. Populate the modbus.yaml file with the values you need. Additional values are listed in the data sheet on the my-pv wifi meter product page. Additional explanation of the config below in the config:
modbus.yaml
# Config modbus MYPV-Meter
- name: "MYPV-Meter"
  type: tcp
  host: 10.2.0.50 #IP of your smart meter
  port: 502
  retry_on_empty: true
  sensors:

# raw data from MYPV Smart Meter
# Combinded value cross phases L1 L2 L3
  - name: "MYPV-Meter Sum W"
    unique_id: mypv_sum_w
    count: 2 # length of the register --> product data sheet
    data_type: int32 # required for accurate values
    scale: -1 #adjust scale if you have other requirements e.g. custom brakets --> see product manual
    address: 32 #address of the reister(DEC)
    unit_of_measurement: W
    state_class: measurement
    scan_interval: 10 #in Seconds

# forward = EK
  - name: "MYPV-Meter Sum EK kWh"
    unique_id: mypv_sum_EK_kwh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 34
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800

# reverse = VK
  - name: "MYPV-Meter Sum VK kWh"
    unique_id: mypv_sum_VK_kwh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 36
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800

#*******************************************	
# Values phase L1 = phase A
#*******************************************

 # Watt - = from grid, + = to grid
  - name: "MYPV-Meter L1 W"
    unique_id: mypv_meter_l1_w_n
    count: 2
    data_type: int32
    scale: -1
    address: 2
    unit_of_measurement: W
    state_class: measurement
    scan_interval: 10

 # kWh Counter to grid forward
  - name: "MYPV-Meter L1 to grid kWh"
    unique_id: mypv_meter_l1_tog_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 4
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800

 # kWh Counter from grid VK
  - name: "MYPV-Meter L1 VK kWh"
    unique_id: mypv_meter_l1_vk_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 6
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800


#*******************************************	
# Values Phase L2 = Phase B
#*******************************************

 # Watt - = from grid, + = to grid
  - name: "MYPV-Meter L2 W"
    unique_id: mypv_meter_l2_w
    count: 2
    data_type: int32
    scale: -1
    address: 12
    unit_of_measurement: W
    state_class: measurement
    scan_interval: 10

 # kWh Counter to grid
  - name: "MYPV-Meter L2 to grid kWh"
    unique_id: mypv_meter_l2_tog_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 14
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800

 # kWh Counter from grid VK
  - name: "MYPV-Meter L2 VK kWh"
    unique_id: mypv_meter_l2_vk_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 16
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800


#*******************************************	
# Values Phase L3 = Phase C
#*******************************************

 # Watt - = from grid, + = to grid
  - name: "MYPV-Meter L3 W"
    unique_id: mypv_meter_l3_w
    count: 2
    data_type: int32
    scale: -1
    address: 22
    unit_of_measurement: W
    state_class: measurement
    scan_interval: 10

 # kWh Counter to grid
  - name: "MYPV-Meter L3 to grid kWh"
    unique_id: mypv_meter_l3_tog_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 24
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800


 # kWh Counter from grid VK
  - name: "MYPV-Meter L3 VK kWh"
    unique_id: mypv_meter_l3_vk_kWh_n
    count: 2
    data_type: int32
    precision: 2
    scale: 0.00125
    address: 26
    unit_of_measurement: kWh
    state_class: total_increasing
    scan_interval: 1800

  1. In “Settings → Services & Devices → Helpers” configure two counters for the kwh IN and OUT
  2. Reload your settings

hi Christoph,
If you want to steer your ELWA-E from HA, you can either do that with Modbus TCP or via a REST http command. It super easy but you need to request the documentation to the MyPV team as they don’t want to publish it openly.
Works perfectly on my system. Just one line of code creating the rest command in the configuration.yaml file and one automation that sends the power value that can be used to the ELWA-E device via the command.

hi @Enzody , since you did probably map all the json values to template, would be cool to share :wink:

nevermind, just did it here thanks to your advices.
Add this to your configuration.yaml file

rest:
  - resource: "http://XXX.XXX.XXX.XXX/data.jsn"
#    scan_interval: 10
    sensor:
      - name: "MyPV Current power usage"
        value_template: "{{ value_json.power }}"
        unit_of_measurement: "W"
      - name: "Hot Water Current temperature"
        value_template: "{{ value_json.temp1 / 10 }}"
        unit_of_measurement: "°C"
      - name: "Hot Water MyPV Target temperature"
        value_template: "{{ value_json.ww1target / 10 }}"
        unit_of_measurement: "°C"
1 Like

Hi together, reading all time by…

Personally im interested in Steering my today installed Elwa2 per EDL21 Data - not by the data provided by the PV-Inverter (reason in my home there is a kaskading Electro system installed)Unbenannt
so i want to use only acess Energy if there is on on the Z1 Power meter…

How are you exactly steering your Elwa-E … any help would be welcome because im not very good in English and way worse in programming…
Thanks in advance…

Hey, that means you are using this integration from zauberertz to monitor the water temperature and use this information to start and stop heating and set the power (0-3500)?

Basically I’m planning to purchase the AC ELWA 2 and I do like to set a base temperature (let’s say 50°C) and if there is a PV-surplus it should start heating (up to let’s say 65°C).

Is the MYPV supporting such an idea?

The how would be then an automation in HA which is basically checking the temperature and if there are certain trigger (need to think about those) the automation will start a python script which is then calculating and setting the power by http set or modbus and switching it on, or off the other way around of course.

Does that make sense?

thx in advance
Christoph

On this im interested… my way till now is a little bit from the other side: First i thougt the zauberertz integration will do the trick. But it´s only good for reading out the monitoring data, not for writing down the work models for the AC-Elwa2.
So i followed the hints in the woods(here in this thread). Long story short right now im getting the data that i wish for my HA right out of the AC-Elwa2 by some lines in my configuration.yaml - per rest command:

rest:
  - resource: "http://xxx.xxx.xxx.xxx/data.jsn"
    scan_interval: 10
    sensor:
      - name: "MyPV Stromverbrauch aktuell"
        unique_id: "mypv_stromverbrauch_aktuell"
        value_template: "{{ value_json.power_elwa2 }}"
        device_class: energy
        unit_of_measurement: "W"
        state_class: total_increasing
      - name: "Trinkwasser Temperatur unten"
        unique_id: "trinkwassertemperatur_unten"
        value_template: "{{ value_json.temp1 / 10 }}"
        device_class: temperature
        unit_of_measurement: "°C"
      - name: "Trinkwasser Temperatur Oben"
        unique_id: "trinkwassertemperatur_oben"
        value_template: "{{ value_json.temp2 / 10 }}"
        device_class: temperature
        unit_of_measurement: "°C"
rest_command:
  update_elwa_power:
    url: "http://xxx.xxx.xxx.xxx/control.html?power={{ power }}"
  update_elwa_pid:
    url: "http://xxx.xxx.xxx.xxx/control.html?pid_power={{ pid_power }}"
  update_elwa_boost:
    url: "http://xxx.xxx.xxx.xxx/control.html?boost={{ 1 }}"

i had to create a helper to measure the exessive Power in watts (which is transported to the grid)
“stromverkauf nach WP-Zaehler”
this helper is getting it´s data from my sensor.smart_meter_negative_active_energy_total_2 (which is in my upper Post the [z1] meter

i have also made an automation to steer my AC-Elwa 2 automaically from my exessive Power

description: ElwaUpdate
trigger:
  - platform: state
    entity_id:
      - sensor.smart_meter_negative_active_energy_total_2
  - platform: state
    entity_id:
      - sensor.master_battery_discharge
condition:
  - condition: sun
    after: sunrise
    before: sunset
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.stromverkauf_nach_wp_zaehler
        above: "4"
      - condition: numeric_state
        entity_id: sensor.master_battery_discharge
        below: "0.1"
    then:
      - service: rest_command.update_elwa_power
        data:
          power: >-
            {{ (((states('sensor.stromverkauf_nach_wp_zaehler') | float -4 )* 40
            + states('sensor.elwa_e_2_mypv_stromverbrauch_aktuell') | float)) *
            0.9 }}
    else:
      - service: rest_command.update_elwa_power
        data:
          power: 0
mode: single



i had to integrate the template to compensate the changing amount of the power by sun + due to the using of my AC-ELWA 2. Also i created a condition where the battery of our house is overwatched so im not consuming battery energy. Also there is a function integrated where my ELWAe2 is completely shutting down (when there is no surplus electric engergy going away from my house and when its after sunset and bevore sunrise)
Plus in my opinion ist better to loose another 0.05 of the energy bevore importing it form the grid / or using the Battery power… (the whole template is normally updating all 5 minutes[-not really its updating when the state of the “sensor.smart_meter_negative_active_energy_total_2” is changing-])

have fun alltogehter…sorry for bad english
Finally edited on 2024.01

hey, thx for the detailed description.
I just need to wait until the AC ELWA 2 is delivered and the I’ll provide feedback how I solved it using your experience!

thx!

hi @Wondolone, not exactly. I just did a rest command that gathers the data.jsn content and parses it in 3 sensors.
AC ELWA E is similar in the code as AC ELWA 2, but I believe the latter has a bit more functionalities and abilities to be steered. ELWA E allows only to be enabled or disabled and accepts as input the desired power. It will warm the water up to the desired temperature which is set with physical button on the device. You can nevertheless read it’s temperature but you do not need to steer anything else than the power.
Request their documentation to play with it, for now, they have not allowed me to share it further.

Hi @sleepymaxx, have you been able to figure out what pid_power is?

/control.html?power=n      while (n) ist the [user/HA/..] /the amount of used energy in your ELWA 0....-3500
/control.html?pid_power=n  **Post edited because of way better explanation by **

[pid_power VS power]( https://community.home-assistant.io/t/mypv-integation-started/395584/83?u=sleepymaxx )
[PID](https://en.wikipedia.org/wiki/Proportional%E2%80%93integral%E2%80%93derivative_controller)

/control.html?boost=n      while (n) is only 0 or 1 / start or stop the Boost function

so if you want not to go aprupt in very high amounts in power change… better use the /control.html?pid_power=n option (to shut down set it on 0 to let the elwa steer slowly down… )

1 Like

Thanks for the details. I got my elwa connected all looks ok.
I have one question, maybe you can provide me some help.
I got shelly 3em as a energy meter for my system, the shelly on solar power give me negative readings, so my question is how you manage to make it work?

I try to figure how but somehow I can’t

And one more, in case we like to make the power of Elwa to change dynamic ( with the changes of solar power ) you have any suggestion?

Thanks in advance.

Hi sleepmax,
thanks for sharing your YAML code here.

I got all the sensor infos via the rest-api from my AC-Elwa 2.
But unfortunately I am not able to submit commands.
Even directly from my WEB browser the command:

http://my-acelwa2/control.html?boost={{ 1 }}
...
responds with: "404 page not found".

Do you have any hints for me

Found my mistake.
To control the AC-Elwa via http, it is necessary to set in "Steuerungseinstellungen>Ansteuerungstyp to http.
In my case it was set to Kostal.

But I will leave it with Kostal, so that my Kostal is still able to control the Elwa2

@showup

you have to get negative readings … only with these you are able to figure out how much energy you are spending to the grid… so i would make a template to calculate how much energy you are exporting and take this for steering my elwa

template:
  - sensor:
      - name: "your_name"
        unique_id: "your_uniqe_id"
        device_class: "energy"
        icon: "mdi:your_mdi"
        state_class: "total_increasing"
        unit_of_measurement: "kWh"
        state: > {{ states('sensor.yourshellysensor') | float *-1 | float }}

after that you take this sensor to steer your elwa.

right your elwa will only be steerable by one input

Thanks for your respond.

Now I see what was missing from my setup.

Thank you.

That here I know. I got from MYPV the info about the elwa and the http.

Thank you

Hi sleepymax.
Can you please help a bit here?

I got my sensors working. Now I got + readings on solar production. My question is how can I control the power of Elwa when the solar power change?
I mean on your code I can see that you check the state of two sensor but somehow i’m not coding master.

I have one sensor show the surplus from my solar.

I can control manual the elwa on/off/power change and all the readings.

Thanks in advance.

P.S. Basicaly what you do here…(?).

power: >-
            {{ (((states('sensor.stromverkauf_nach_wp_zaehler') | float -4 )* 36
            + states('sensor.elwa_e_2_mypv_stromverbrauch_aktuell') | float)) *
            0.95 }}

Here is my yaml
alias: ElwaON
description: ElwaON
trigger:

  • platform: state
    entity_id:
    • sensor.vxxout
      condition:
  • condition: sun
    after: sunrise
    before: sunset
    action:
  • if:
    • condition: numeric_state
      entity_id: sensor.vxxout
      above: 800
    • condition: numeric_state
      entity_id: sensor.vxxin
      below: 0.1
      then:
    • service: rest_command.update_elwa_power
      data:
      power: >-
      {{ (((states(‘sensor.vxxout’) | float -4 )* 36 +
      states(‘sensor.elwaxx_power’) | float)) * 0.95 }}
      else:
    • service: rest_command.update_elwa_power
      data:
      power: 0
      mode: single

What that means:
)* 36 +

  • 0.95

Sorry for the trouble…I start with HA last month…A lot to learn.