petrleocompel / hikaxpro_hacs

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

Refactor binary sensors #91

Open Drealine opened 7 months ago

Drealine commented 7 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 7 months ago

Magnet "presence" is binary_sensor

petrleocompel commented 7 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 7 months ago

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

petrleocompel commented 7 months ago

I feel like you mixing up dev terminology and ui terminology

Drealine commented 7 months ago

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

petrleocompel commented 7 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