petrleocompel / hikaxpro_hacs

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

Refactor binary sensors #91

Open Drealine opened 10 months ago

Drealine commented 10 months ago

Hi It's me again. Did you think it can be more usual to have magnet open detection as binary_sensor and not as sensor in HA ? Thank you

petrleocompel commented 10 months ago

Magnet "presence" is binary_sensor

petrleocompel commented 10 months ago

https://github.com/petrleocompel/hikaxpro_hacs/blob/61aa83c1264b1d11811189bebec70d180db4d1f9/custom_components/hikvision_axpro/sensor.py#L172 https://github.com/petrleocompel/hikaxpro_hacs/blob/61aa83c1264b1d11811189bebec70d180db4d1f9/custom_components/hikvision_axpro/sensor.py#L228 https://github.com/petrleocompel/hikaxpro_hacs/blob/61aa83c1264b1d11811189bebec70d180db4d1f9/custom_components/hikvision_axpro/sensor.py#L282 https://github.com/petrleocompel/hikaxpro_hacs/blob/61aa83c1264b1d11811189bebec70d180db4d1f9/custom_components/hikvision_axpro/sensor.py#L349 https://github.com/petrleocompel/hikaxpro_hacs/blob/61aa83c1264b1d11811189bebec70d180db4d1f9/custom_components/hikvision_axpro/sensor.py#L416

All of them are BinarySensorEntity

Drealine commented 10 months ago

It's strange. All sensors of MagnetShockDetector are sensor.* and not binary_sensor.. See bellow : image

petrleocompel commented 10 months ago

I feel like you mixing up dev terminology and ui terminology

Drealine commented 10 months ago

Yes you've reason. So the FR is for UI.

petrleocompel commented 10 months ago

Okay UI see now what you mean. Refactor will be to change move those from sensor.py to binary_sensor.py and initialize them as binary sensors. Sadly not too easy you can expect such a thing in next release 2.2.0