Assign "area" to entities in configuration.yaml

I would love to be able to define/assign areas in YAML config.

Simple example, I define a sensor:

template:
  - sensor:
    - name: Bedroom Thermometer
      state: "{{ states('sensor.th01_sonoff_snzb_02_temp_humid_temperature') }}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
      area: Bedroom

See what I did there? Yeah, it is a config error –> I cannot assign the area in the sensor’s definition.

As far as I understand, I’m required to assign a unique_id (which is not useful for me for anything – I assume it is just a strange quirk to make HA’s internals work) and assign the area via WebUI later.

The problem is: why would I bother to define the sensor in YAML in the first place then? If I cannot define it completely? Would you suggest I get rid of YAML and define the sensor via WebUI after all? I hope not…

YAML has it’s advantages… I don’t think this is the place to argue for them. Unless you want me to.

That could be one way to possibly assign areas (assign them directly when defining sensor).

The other could be more “centralized”:

area:
  living_room:
    - device: shelly_1
    - device: shelly_2
    - entitiy: shelly_3_today
  dining_room:
    - 

Also:

Don’t forget to vote for your own FR.

1 Like