mnordseth / enet-homeassistant

Enet Smart Home integration for Home Assistant
Apache License 2.0
26 stars 7 forks source link

Switches and Battery Sensor #28

Closed ChrisSoelder closed 2 months ago

ChrisSoelder commented 2 months ago

Hi Magnus!

Since you merged already my previous PR, I've 2 subsequent features already implemented :)

  1. Add Switch Domain: Actuators that are configured as switches (ChannelApplicationMode.SWITCHING) instead of light switches (ChannelApplicationMode.LIGHT_SWITCHING) or light dimmers (ChannelApplicationMode.LIGHT_DIMMING) will now correctly be represented as switches and not lights IMPORTANT: This is a breaking change für already existing entities with ChannelApplicationMode.SWITCHING, since they will be moved from light domain to switch domain. This results in the entities being newly created as switches, while the "old lights" will have to be removed manually from HA
  2. Add Battery State Sensor for devices that have one
  3. Added translation for German

Testing: I'currently testing with my own eNet setup at home: Server-Version: 2.4.0 Server-Hardware: 2 Home-Assistant: HA 2024.5.4

DeviceTypes: DVT_DA1M DVT_US2M DVT_SA1M DVT_SA2M DVT_SD1M DVT_SF1S DVT_SV1M DVT_JA1M DVT_WS1BG DVT_WS3BG

mnordseth commented 2 months ago

Hi, I merged this and added a fix to EnetCoordinator._async_update_data() which should never return. Also, I have plans to move event handling to aioenet at some point to be more in line with other integrations and libraries.

ChrisSoelder commented 2 months ago

Thanks Magnus! I thought that the event registration was ok this way, but as i said I'm quite new to Homeassistant and Python :) If you need any help or want to work together on this, let me know!

My next goal for now is to get the integration feature complete in the sense that it can completely replace the original App. The only thing missing for me atm would be to get the info about forced states for the actuators(wind alarm etc.) into home assistant. So that I for example can see when the Blinds are blocked. Shouldn't be much work I hope....

Btw. I set up a Postman collection to run and test requests against the enet server as well as reverse engineer some API calls. If it can help you I will gladly give you an invite to the project!

mnordseth commented 2 months ago

From what I can see, you know how to write python, at least compared to me who hasn't done that actively for the last 10 years...

I think the recommendation from Home Assistant, is to try to keep the low level library that communicate with the Enet server decoupled from HA, and ideally it should live in it's own library. I have used the Philips Hue integration as inspiration, and there you have a separate aiohue library (https://github.com/home-assistant-libs/aiohue)

Considering this, I think we should move get_device_info() into EnetBaseEntity.

As for the event loop, I have started to implement the event handling in aioenet, so the intention is that in HA, the entities and devices register callbacks to EnetClient. Feel free to take a look, or I will try to jump in over the next days.