Aohzan / ipx800

IPX800 V4 integration for Home-Assistant
Apache License 2.0
20 stars 12 forks source link

Add value_template option #39

Closed MacGeyer closed 8 months ago

MacGeyer commented 1 year ago

I need to use "analogin" or "virtualanalogin" type but I also need to add some calculations, could you add value_template option please or do you have another solution to map IPX800 sensor formulas to Home Assistant ?

Aohzan commented 1 year ago

Hello, You should use template entities https://www.home-assistant.io/integrations/template/#state-based-template-binary-sensors-buttons-numbers-selects-and-sensors

MacGeyer commented 1 year ago

Yes I use this workaround currently :

ipx800v4:
  - name: IPX800
    host: "10.0.0.102"
    api_key: "apikey"
    devices:
      - component: binary_sensor
        name: Filtration Piscine
        type: digitalin
        icon: mdi:pump
        id: 1
      - name: RAW PH Piscine
        icon: mdi:water-boiler
        type: "virtualanalogin"
        component: "sensor"

        id: 29
      - name: RAW RedOx Piscine
        icon: mdi:water-boiler
        type: "virtualanalogin"
        component: "sensor"
        id: 30

template:
  - sensor:
      - name: "Calc PH Piscine"
        state: "{{ (((states.sensor.raw_ph_piscine.state) | float) / 100) | round(1) }}"
        unit_of_measurement: ""
      - name: "Calc RedOx Piscine"
        state: "{{ ((states.sensor.raw_redox_piscine.state) | int) - 2500 }}"
        unit_of_measurement: mV

Do you plan to add this to your roadmap ? GCE should add the existing formulas to their API access don't you think so ?

Aohzan commented 1 year ago

No because it's better to you use official template entities like you do, raw value in ipx800v4 integration, calculated value in template, as you will get all supported functions and filters, and nothing to maintain on my side. I don't see what is the "existing formulas" ?

MacGeyer commented 1 year ago

When using analog entries (virtual or not) in IPX800 you can add formulas at http://X.X.X.X/admin/analogVirt.htm like I did for the X200-PH image This way iin IPX800 raw values will never have be used, I think it shouldn't have to be used in status or API anyway ! https://wiki.gce-electronics.com/index.php?title=X-200PH#Valeur_.3E_Analogue

Aohzan commented 1 year ago

ahhh indeed I don't understand why GCE doesn't return the real value :thinking: maybe you can ask them ?