Hey there,
I was doing my first steps in HA development, by contributing to a component I’m using: I’m adding turn_on/turn_off support to this camera custom component: https://github.com/gman-php/reolink/tree/turn-on-off-support
Two things though came up to my mind which I couldn’t answer, even after reading through the “Building integrations” section (https://developers.home-assistant.io/docs/creating_platform_index):
- The component I contribute to extends the Camera component. The camera component defines an async and a sync version of turn_on/turn_off. I have now implemented the async versions in the custom components and it works fine. My questions though:
- Do I also have to implement the sync versions?
- How does HA decide if it calls the sync or the async version? I saw this thread here, but that doesn’t 100% answer it: Async_setup_entry() and synchronous component - is it possible?
Or is it determined on which setup() is implemented? So if the component implements async_setup(), HA will only call async version of the functions and the sync ones can be ignored? But why does the camera component then have both versions at all, having the sync ones return “NotImplemented” exception?
- services.yaml: If I inherit from a component, in this case the Camera component, do I also need to list all services again, even if the Camera component has definitions for them already? The custom component I’m contributing to has a few service definitions in there which are already listed by the Camera component. But if I look at the Developer Tools => Services section, I can also see the definitions for turn_on/turn_off there when selecting the camera using that custom component. So I guess I don’t have to do add the definitions there? They are just inherited?
Thanks and greetings,
Andy!