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

I’ll add that at least for some entities, you cannot define a unique_id manually yourself, and thus cannot assign an area at all, period.

An example of this is the media_player.yamaha integration:

media_player:
  - platform: yamaha
    host: amp.static.example.com
    zone_names:
      Main_Zone: "Livingroom"
    source_names:
      AV4: Chromecast
      TUNER: Radio
      HDMI1: TV
    zone_ignore:
      - "Zone_2"

As this integration does not provide a unique_id and there is no unique_id value for me to set, this amplifier cannot be assigned to any area without this FR, or improvements in the Yamaha integration that fake a unique_id, or allow me to make up one myself.

Use the other yamaha integration, it provides unique_id’s. Yamaha network receivers had plans for updates, however it has been plagued with issues. I believe the changes were rolled back because it was causing more issues than it solved.

I only see one Yamaha integration in the official repo, so I’m assuming you mean something in HACS? Sure, I’ll have a go. But, for this FR, I could have worked around this and make it work “good enough” if I could define the area myself for YAML entities. From my point of view this FR would have solved all the other issues without needing to go find an unofficial separate integration.

Nope, Yamaha MusicCast integration.

It works with most yamaha network receivers, although there are models that do not work with it.

Ah, it doesn’t have Yamaha in the name, hence why the search didn’t find it. Thanks! Unfortunately it tells me unknown during config, so my venerable RX-V671 is probably one of those unsupported models on account of being over a decade old.

Reading all the Yamaha bugs makes it seem like there’s perhaps something unsupported even in the other integration since I’m not receiving a unique_id at all, but I’ll dig into that separately to hack something together and fake it to have one.

The integration has never used a unique_id. You will not get a unique_id from the Yamaha Network Reciever integration.

Does this mean that HA really needs to start making unique_id mandatory for integrations (and put in area at the same time)?

I do believe it’s required on the new quality benchmarks. One of the lower tiers has it as required if I’m not mistaken…