Can someone explain what a "Platform" is?

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.

3 Likes

Not the clearest of explanations, but:

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…

2 Likes

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?

It’s both.

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.

1 Like

see my edit

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.

media_player:
  - platform: bluesound
    hosts:
        - host: 192.168.2.66
          name: Barn Node2

The bluesound platform will reside in the bluesound integration files. Platforms do not make devices, they only make entities.

1 Like

Get ready for my weird imagination :grinning:;

  • platforms correspond to entities, you can have switch, light, camera, climate entities.
  • integrations define which platforms they will depend on and can create entities under these platforms.

In your example, you are defining a new light entity derived from switch platform.

I am done with my own bullshitting :slight_smile:

I add another question on this topic…:
So … where can I find the documentation for this initial example:

light:
  - platform: switch
    name: Barn Flood Light
    entity_id: switch.barn_flood_light

Where can I read which attributes (e.g.: name, entity_id) are available for “mapping” a switch to a light ?

Later edit:
It seems that it existed … .but it was removed …
I found it on webarchive from a coupple of years ago: Light Switch - Home Assistant

1 Like

That integration still exists in the UI.

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 :stuck_out_tongue_winking_eye: 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…

2 Likes

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.

1 Like

Feel free to contribute your improvements. It’s all open-source.

FYI, they are described in the developer documents.