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…

  - 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.

1 Like

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…

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.

  - platform: bluesound
        - host:
          name: Barn Node2

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

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:

  - 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

That integration still exists in the UI.