Assign a template binary sensor to an area

I have the following set up to map a tilt sensor to an open / closed state on my garage door:

binary_sensor:
  - platform: template
    sensors:
      car_garage_door:
        friendly_name: "Car garage door"
        unique_id: car_garage_door_state
        device_class: door
        value_template: >-
          {{ state_attr('binary_sensor.car_garage_door', 'tiltangle')|float > 60 }}

While I can see the sensor in the UI, it uses a different ID of binary_sensor.car_garage_door_3 and I can’t assign the sensor to an area. Is this possible?

I believe if you give it a unique_id this should be possible.

Is there something about the format about the unique ID that I’ve missed above?

You can only assign devices to areas. Not entities.

I have heard yesterday that entities will be assignable to areas in the upcoming release.

1 Like

That’s great to hear! I’m not seeing anything obvious in the git logs for the template component, or any notes at https://rc.home-assistant.io/blog/2020/12/02/release-10/. Either way, it will be something to check out in a few weeks.

I updated today, and I can now assign my template sensor to an area. However, it still shows up in the unassigned row in the dashboard instead of the card for the area.

What is this ‘card for the area’ of which you speak? You’re the second person to mention an ‘area card’ in the last week or so, and I have no idea what it is and can’t find any information about it - give me a clue please?

If you use the default automatic dashboard (“Overview”), individual items are grouped together based on the area they are assigned to. Otherwise, they show up at the top of the dashboard in a single row.

Interesting for 2 reasons.

1 - I tried creating a brand new dashboard with default settings and this didn’t happen for me.

2 - the ability to do this should be available as a card for any other view.

Would you be so kind as to take a screenshot of the card for me so I can try and engage with a frontend dev about it and show them what’s missing please?

Here it is:

Note how there’s a card for Andrew’s Office, Basement, etc, but the “Car Garage Door” template sensor stays at the top.

1 Like

Cheers, I’ll borrow that screenshot and open an issue on github later to see if I can get to the bottom of it :+1:

Hi, did you opened the github issue ?

I have the same kind of issue explained here; where light.template (in my case, but its still a template thing) configured with both an unique_id and an area, but can’t be found in lovelace cards : Set "area" for template entities?