I consider myself a power user of HA and i’d like to get further under the covers in general and start to do some custom front-end and perhaps back end development. I’m a long time developer (C++, Java, Python, plus lots others) and very comfortable with large scale architecture. I’ve read all the developer and other documentation that I believe is out there.
For the life of me i still can’t figure out what a “platform” is or how to think about it conceptually. I fully get the nuances of integrations, devices, and entities/state objects. But in reading the documentation I still can’t figure out what a platform is and how it fits into the architecture. For instance I have the following in my configuration.yaml…
light:
- platform: switch
name: Barn Flood Light
entity_id: switch.barn_flood_light
So light is one of the native integrations and i’m defining one of my entities of type “switch” domain (switch.barn_flood_light) as an entity that uses the light integration? What is the switch platform doing in this example?
Sorry for the basic question and if i’ve missed a document somewhere I am happy to do more homework.
Yep been all over that and read it a few times…doesn’t really explain platforms though. Maybe i’m too old school OO developer/architect. Or maybe its just not written well but I can’t make any sense of it for platforms…
Platforms allow you to hook into the integration or domain via your integration.
That example you have there is the switch integration creating a light. The switch platform is a bunch of code that tells light how to create the light entity using all the accompanying yaml.
So is switch an integration or a platform? Light is an integration i know but i thought switch was similar and one of the standard out of box integrations?
Think of the switch platform as the blueprint for the light integration. This blueprint helps the switch platform create the light entity. All the code for the switch platform resides in the switch integration.
The light integration says “Hey switch platform, make me this light, here’s the configuration”. Then the switch integration pops out a light entity.
Ok i’m getting there and i appreciate the help and patience. So can you describe this on an example of a less standard integration/platform. What about this example where I have the media_player integration (i assume?) and the platform is my bluesound streamer. Some code/component somewhere needs to manage the talking to/from the bluesound device. Is that the “bluesound” platform? Interestingly that device is not listed in my devices but it does show up as an entity.
I also share your confusion and frustration at trying to get your head around this. I’m a physicist with many years experience in teaching & design of Analog & Digital Electronics, Control Systems, Measurment Instrumentation and Computer Networking… and this concept still eludes me after multiple readings of the documentation and examples. I think the closest I got to a ‘bell ringing’ was reading the archive article referenced “Light Switch Homeassistant” which had the magic word for me ‘exposes’ in it… sometimes I think I have it but then I can’t see how a ‘platform’ is an integration…sorry it’s still a muddle in my head…
Yeah, as an actual systems engineer (40+ years) I find it maddening how HA mushes together computer science terms-of-art with their own new definitions, or makes up totally new terms for core concepts such as ‘inheritance’… and then fails to write (or ever update) any concept level documentations.
Fragments of YAML code without context or location makes for neither good design docs nor a good tutorial. People new to HA, even skilled developers, spend a staggering amount of time just fighting with syntax and scoping, instead of actually implementing solutions.