Climate YAML difference

Can someone help me explain the difference between these two things (both appear to work perfectly)?

action: climate.set_temperature
data:
  entity_id: climate.my_thermostat
  temperature: 78
  hvac_mode: cool

vs

action: climate.set_temperature
data:
  temperature: 78
  hvac_mode: cool
target:
  entity_id: climate.my_thermostat

i believe they are functionally the same. but that they are older and newer methods of specifying the same thing. i think the “target” one is now preferred.

Ah ok - that would explain the difference between so many service call examples and what the UI generates now. Thanks!

The use of target allows the action to be called not just on a list of entities, but also on devices, areas, or labels… or any combination of entities, devices, areas, and labels.

I’m not familiar with “devices”, what would that be used for?

Areas and labels seem self explanatory, though I don’t think I presently have a usecase since I have already been using groups to mix and match combinations of things more dynamically

Devices represent a physical or logical unit that contains entities. Your climate entities are likely each part of a device that represents the collection of climate, sensor, and other types of entities that are provided by the thermostat and its integration. When you use a device as the target (much like when you use area) HA calls the service on any applicable entity that is part of the device. If you call light.turn_off on a device, all the device’s entities that are in the light domain will be tuned off.

Depending on how dynamic you want to be, you might want to take a look at Spook and consider using labels instead of groups, at least for some purposes. Spook adds a lot of label actions that make them more flexible than groups.

I will have to look at that. Usually I put the groups and dynamic bits on the inputs, for example there’s a half dozen reasons I may want the front outside light switch turned on so all those are in a big group triggering the automation to turn it on/off (but there’s 1 light switch for the front ouside lights, so I only have 1 thing to turn on/off)

I honestly haven’t done much for labels or areas because it felt redundant to label the front outside light switch or livingroom light when its the only thing that fits that label or location