petrleocompel / hikaxpro_hacs

HACS repository of Hikvision Ax Pro integration for home assistant
MIT License
45 stars 4 forks source link

State of magnets #27

Closed leciuk81 closed 1 year ago

leciuk81 commented 1 year ago

HI I wanted to ask you if it was possible to change the state of the magnets from: on - open in open - closed and also if it was possible to color the icon according to the state when it risks being open. Thanks for the excellent job you are doing.

petrleocompel commented 1 year ago

We are using https://developers.home-assistant.io/docs/core/entity/binary-sensor With class BinarySensorDeviceClass.PRESENCE

Like it would be possible but my target was to keep it closes to the docs as possible. If there will be any similar attributes they would be also on/off to stand with KISS principle.

Having everything in on/off state seems later better for automations and other scripts or blueprints.

petrleocompel commented 1 year ago

Color of icon is possible I guess. I will see what we can do.

leciuk81 commented 1 year ago

Thank you Meanwhile, I report at the bottom how I got the open and closed writings by adding a sensor in sensors.yaml

  - platform: template
    sensors:
      sensore_finestra_stanzetta_axprohikvision:
        friendly_name: "Sensore finestra stanzetta axprohikvision"
        value_template: >-
          {% if is_state('sensor.centrale_allarme_ax_pro_magnet_4', 'on') %}
            chiusa
          {% elif is_state('sensor.centrale_allarme_ax_pro_magnet_4', 'off') %}
            aperta
          {% else %}
            fallito
          {% endif %}
petrleocompel commented 1 year ago

Sad news for you. Color change is not possible. But there are some possibilities outside of integration. https://community.home-assistant.io/t/dynamic-icons-and-icon-colors/219595/16

But also i am confused. Currently we are reporting inverted state !! Means "magnet detected = off" and "magnet not detected = on".

This should change 🫤 to match the "presence" if magnet is present we should report "On"

leciuk81 commented 1 year ago

But also i am confused. Currently we are reporting inverted state !! Means "magnet detected = off" and "magnet not detected = on".

This should change 🫤 to match the "presence" if magnet is present we should report "On"

It actually gets confusing and that's why I wanted to change. But all this is correct though as the hikvision magnet is a normally open contact.

petrleocompel commented 1 year ago

Well I was unable to understand that from original "description" from you. I think i will have to change it.

leciuk81 commented 1 year ago

There are normally open and normally closed magnets. This does not indicate the state of the window or the door where it is installed but only its own state. As you said well in the case of the use that we do some magnet is as if it worked on the contrary but it is only a matter of logic. If you find yourself better to work so you can safely continue to develop without touching anything but I believe that sooner or later it should be associated with the real use that we all make and therefore make it open (off) and closed (on)

petrleocompel commented 1 year ago

It is already implemented #29 It is better later it follows HA developer docs. So it will be a breaking change. so finally major release. v1.0.0

petrleocompel commented 1 year ago

With next release this will be fixed. Wait for version v1.0.0.