Hi guys,
I just started developing and integration for a Norwegian alarm company, Homely. They have a pretty straightforward rest API as well as a websocket for streaming events. I’m having some trouble getting the web socket to authenticate properly, so for now I’m focusing on the rest interface. I have built a very simple client wrapper: GitHub - kolaf/homelypy: A thin wrapper for the Homely alarm company API Which I will use for the integration.
I have managed to set up a configuration flow to deal with authenticating the user with the service and selecting the correct home for retrieving the data inside the service. I have also managed to create a very simple binary sensor platform to deal with the door sensors provided by the alarm system. However, this is where things start falling apart for me.
You can find my simple beginnings here: core/homeassistant/components/homely at homely · kolaf/core · GitHub
There is a single endpoint that provides information about all the devices and the state of their various entities. For instance, a door sensor has an alarm entity that deals with whether it is open or closed, a temperature entity, and a battery state.
I have created a data coordinator together with a window sensor entity based on the binary sensor entity, and I have successfully used this to create a device together with the binary sensor entity for the door open state. However, I am not sure how to generalise this. As mentioned above the single device supports several entities, but for now both the coordinator and the device information is defined inside the binary sensor platform. How do I best generalise this so that I can create the various types of entities (binary sensor, temperature sensor, battery state) that are tied to this single device? Do I have to implement different platform files for each of the entity types and be sure to define the same device info for each entity? I assume I can reuse my data coordinator for all the devices by simply moving it to a separate file instead of keeping it inside the binary sensor file, correct?
I realise that this is a lot to explain in a forum post, so is there perhaps some developer documentation that deals with this I had missed? I could also create a pull request for my changes if that makes discussing this easier, but since the code is nowhere near ready for official review I didn’t want to put it into the official system.
Thanks for your help.