klatremis / esphome-for-deye

Esphome component for Deye 3 phase inverters for Home Assistant
113 stars 30 forks source link

Total PV Power #20

Closed Adminius closed 8 months ago

Adminius commented 9 months ago

Hi, Deye sends PV1 and PV2 separated only. Sometimes it's better to have total PV power already calculated

The only solution I could find until now:

sensor:
  - platform: template
    name: "${device_type}-Total PV Power"
    id: ${device_type}_Total_PV_Power
    unit_of_measurement: "W"
    state_class: "measurement"
    accuracy_decimals: 0
    lambda: |-
      return (id(${device_type}_PV1_Power).state + id(${device_type}_PV2_Power).state);
    update_interval: 5sec

But it's not synced (=> delayed) with PV1 and PV2 power, because it's not triggered by PV1 or PV2. Is there any better solution for it?

MyHekla commented 9 months ago

I have a similar calculation - but don't use the 'updateinterval'

Adminius commented 9 months ago

but don't use the 'updateinterval'

It looks like HA Code and not ESPHome. I tried without update-interval and it doesn't worked at all (directly on esp32)

Adminius commented 9 months ago

Hm, now I'm testing this solution:

  - platform: modbus_controller
    modbus_controller_id: ${modbus_controller_id}
    name: "${device_type}-PV1 Power"
    id: ${device_type}_PV1_Power
    register_type: holding
    address: 672
    unit_of_measurement: "W"
    state_class: "measurement"
    accuracy_decimals: 0
    value_type: U_WORD
    on_value:
      then:
        - component.update: ${device_type}_Total_PV_Power

  - platform: modbus_controller
    modbus_controller_id: ${modbus_controller_id}
    name: "${device_type}-PV2 Power"
    id: ${device_type}_PV2_Power
    register_type: holding
    address: 673
    unit_of_measurement: "W"
    state_class: "measurement"
    accuracy_decimals: 0
    value_type: U_WORD
    on_value:
      then:
        - component.update: ${device_type}_Total_PV_Power

  - platform: template
    name: "${device_type}-Total PV Power"
    id: ${device_type}_Total_PV_Power
    unit_of_measurement: "W"
    state_class: "measurement"
    accuracy_decimals: 0
    lambda: |-
      return (id(${device_type}_PV1_Power).state + id(${device_type}_PV2_Power).state);

total_pv_power should be updated each time PV1 or PV2 gets new value. let's see

Adminius commented 8 months ago

my solution from previous post works pretty well, the only thing I changed: "on_value" only for PV2, because PV1 und PV2 are updated at the same time, it doesn't make sense to calucalate ithe sum two times.