Egyras / HeishaMon

Panasonic Aquarea air-water H, J, K and L series protocol decrypt
242 stars 122 forks source link

heishamon.yaml updated #250

Closed edterbak closed 2 months ago

edterbak commented 2 years ago

HomeAssistant changed the designation of mqtt sensors and switches. https://www.home-assistant.io/integrations/switch.mqtt/ https://www.home-assistant.io/integrations/sensor.mqtt/

This impacted heishamon.yaml. I have updated it already, and it is ready to use. working with HomeAssistant from release month 6-2022

text from HA release notes:

As an example, this is now deprecated:

sensor:
  - platform: "mqtt"
    name: "My sensor"
    state_topic: "some-state-topic"

The configuration needs to be updated to this format:

mqtt:
  sensor:
    - name: "My sensor"
      state_topic: "some-state-topic"

Also the mqtt switch has changed. all is reflected in attached txt file. See latest attachment below

edterbak commented 2 years ago

Note that you need to change the extension of the file. Github does not allow direct yaml. File name should be: heishamon.yaml

edterbak commented 2 years ago

Added a new version which corrects some bits.

it could do with some checking by someone :)

kampsj commented 2 years ago

Added a new version which corrects some bits.

it could do with some checking by someone :)

Nice work! Why not also migrate the legacy template sensors to their new format? I've added an (untested) example below.

template:
  - sensor:
      - name: "heishamon_w_production"
        unit_of_measurement: 'W'
        state: >-
          {%- if states('sensor.aquarea_dhw_power_produced') != "0" -%}
            {{ states('sensor.aquarea_dhw_power_produced') }}
          {%- else -%}
            {{ states('sensor.aquarea_power_produced') }}
          {%- endif -%}
      - name: "heishamon_w_consumption"
        unit_of_measurement: 'W'
        state: >-
          {%- if states('sensor.aquarea_dhw_power_consumed') != "0" -%}
            {{ states('sensor.aquarea_dhw_power_consumed') }}
          {%- else -%}
            {{ states('sensor.aquarea_power_consumed') }}
          {%- endif -%}
       - name: "heishamon_cop"
         unit_of_measurement: "x"
         state: >-
          {%- if states('sensor.heishamon_w_production') != "Unknown" -%}
            {%- if states('sensor.heishamon_w_consumption') > "0" -%}
              {{ '%0.1f' % ((states('sensor.heishamon_w_production') | float ) / (states('sensor.heishamon_w_consumption') | float)) }}
            {%- else -%}
              0.0
            {%- endif -%}
          {%- else -%}
            n/a
          {%- endif -%}
edterbak commented 2 years ago

Added a new version which corrects some bits. it could do with some checking by someone :)

Nice work! Why not also migrate the legacy template sensors to their new format? I've added an (untested) example below.

template:
  - sensor:
      - name: "heishamon_w_production"
        unit_of_measurement: 'W'
        state: >-
          {%- if states('sensor.aquarea_dhw_power_produced') != "0" -%}
            {{ states('sensor.aquarea_dhw_power_produced') }}
          {%- else -%}
            {{ states('sensor.aquarea_power_produced') }}
          {%- endif -%}
      - name: "heishamon_w_consumption"
        unit_of_measurement: 'W'
        state: >-
          {%- if states('sensor.aquarea_dhw_power_consumed') != "0" -%}
            {{ states('sensor.aquarea_dhw_power_consumed') }}
          {%- else -%}
            {{ states('sensor.aquarea_power_consumed') }}
          {%- endif -%}
       - name: "heishamon_cop"
         unit_of_measurement: "x"
         state: >-
          {%- if states('sensor.heishamon_w_production') != "Unknown" -%}
            {%- if states('sensor.heishamon_w_consumption') > "0" -%}
              {{ '%0.1f' % ((states('sensor.heishamon_w_production') | float ) / (states('sensor.heishamon_w_consumption') | float)) }}
            {%- else -%}
              0.0
            {%- endif -%}
          {%- else -%}
            n/a
          {%- endif -%}

Hi, Yeah, I did not see this yet. I have no experience handling the template sensors. Could you maybe have a go at it? I will replace the one in my post with the updated one from you then *(with mentions to you)

:)

edterbak commented 2 years ago

I gave it an attempt, Looking at your code, it is fairly similar. I have removed the - in the %- -% codes, that is the only difference I can spot.

See attached file here.

see latest download below

I do see there is a potential issue that the value can be unknown, throwing an error. Does anyone know how to tackle that?

thanks

MiG-41 commented 2 years ago

Beouse you dont have any sensor.heishamon_w_production and sensor.heishamon_w_production ? You should have something like sensor.aquarea_power_produced and sensor.aquarea_power_produced ( acc to #TOP15 and #TOP16) . This entities names can be checked i.e. in development menu.

edterbak commented 2 years ago

I get some errors during startup,

TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{% if states('sensor.heishamon_w_production') != "Unknown" %} {% if states('sensor.heishamon_w_consumption') > "0" %} {{ '%0.1f' % ((states('sensor.heishamon_w_production') | float ) / (states('sensor.heishamon_w_consumption') | float)) }} {% else %} 0.0 {% endif %} {% else %} n/a {% endif %}' but no default was specified') while processing template 'Template("{% if states('sensor.heishamon_w_production') != "Unknown" %} {% if states('sensor.heishamon_w_consumption') > "0" %} {{ '%0.1f' % ((states('sensor.heishamon_w_production') | float ) / (states('sensor.heishamon_w_consumption') | float)) }} {% else %} 0.0 {% endif %} {% else %} n/a {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.aquarea_cop'

I will look into it further in a couple of days. But if someone KNOWS what is wrong and willing to fix it, I do not mind :)

edterbak commented 2 years ago

I think this is better:

See latest download below

after boot, there is no error anymore now. But im unsure.

edterbak commented 2 years ago

Again, can someone please check if this is right?

I do not use the heishamon package .yaml in HomeAssistant myself. I use node red.

kampsj commented 2 years ago

I guess I forgot that I have renamed the sensors in my personal yaml.

I will do some testing this weekend (and rename my sensors).

Maarten69 commented 2 years ago

@edterbak I've updated with your heishamon.yaml on latest Home Assistant v 2022.6.6 and all working fine, thanks!

edterbak commented 2 years ago

@edterbak I've updated with your heishamon.yaml on latest Home Assistant v 2022.6.6 and all working fine, thanks!

Can you check on the s0 meter if that is all ok? I got feedback from one other that some naming was changes.
I am having difficulty to understand how this change / error happend. Better to double check if there is an error here or not :)

kampsj commented 2 years ago

@edterbak

Your naming of the s0 meter is off. - name: S0 meter - Solar power Production and - name: S0 meter - Solar power Production Total versus name: Aquarea Metered Power Consumption and Aquarea Metered Power Consumption Total for S0_1. Naming of S0_2 is also not identical, which is probably the cause.

edterbak commented 2 years ago

@edterbak

Your naming of the s0 meter is off. - name: S0 meter - Solar power Production and - name: S0 meter - Solar power Production Total versus name: Aquarea Metered Power Consumption and Aquarea Metered Power Consumption Total for S0_1. Naming of S0_2 is also not identical, which is probably the cause.

Is this the only thing 'off'? If so, I can correct it. But if there is more, (and I still dont understand how this happend) I will throw it away and start over to be sure there are no other mistakes.

kampsj commented 2 years ago

@edterbak I've checked your latest file against the latest version (https://github.com/Egyras/HeishaMon/blob/master/Integrations/Home%20Assistant/heishamon.yaml) and have made a few changes to sync both files.

Note that I've opted to keep the legacy templates as is.
heishamon.yaml.txt

Maarten69 commented 2 years ago

The naming was off, like kampsj stated. I mentioned this also on GoT. Now all working fine.

edterbak commented 2 years ago

@kampsj When I import your latest .txt, I get errors. I started over, with the choose to use of legacy templates now. Maybe later the newer version.

I think there is an indentation difference.

mqtt:
  sensor:
    - name: ....
    - name
    - name
....
....
  sensor:
    - platform: template
      sensors:
        heishamon_w_production:

The lower part with platform template is i should be:

mqtt:
  sensor:
    - name: "xxx"
    - name: "yyy"
    - name: "zzz"
....
....
sensor:
  - platform: template
    sensors:
      heishamon_w_production:

The below version works for me, even after reboot. I dont know how you get your version working 😄 heishamon - 23-6-2022.yaml.txt

am I missing something or am I just ignorant ghehehee..

Hopefully I am actually helping here, instead of making a mess.

kampsj commented 2 years ago

@edterbak You're right. There were a few (3) errors in my file. I've fixed them in the file below.

heishamon.yaml.txt

edterbak commented 2 years ago

I confirm. Our latest versions are now both identical. (give or take some extra lines in between) Both work.

But both are in old template format, which I dont bother with.

edterbak commented 2 years ago

https://github.com/Egyras/HeishaMon/blob/c595ec074d8e9d8640ec10dc6a8535b1e31be226/Integrations/Home%20Assistant/heishamon.yaml

I see our work is outdated. pullrequest with updated heishamon.yaml already in there. Hahaha...