How to assign a template sensor to an area (zone of the house)

Hi!

I have some template sensors which are taking their data from a Raspberry Pi, published through JSON at a REST endpoint. My HA config looks like this:

# Raspberry Pi (REST)
- platform: rest
  name: RaspberryPiSensors
  resource: http://192.168.0.222:5555/sensor
  scan_interval: 60
  json_attributes:
    - temp_boiler_room
    - temp_outdoor
    - temp_stairwell
  value_template: 'Sensor'
      
# Raspberry Pi (broken out)
- platform: template
  sensors:
    temp_boiler_room:
      friendly_name: Boiler room temperature
      value_template: '{{ states.sensor.raspberrypisensors.attributes["temp_boiler_room"] }}'
      device_class: temperature
      unit_of_measurement: '°C'
    temp_outdoor:
      friendly_name: Outdoor temperature
      value_template: '{{ states.sensor.raspberrypisensors.attributes["temp_outdoor"] }}'
      device_class: temperature
      unit_of_measurement: '°C'
    temp_stairwell:
      friendly_name: Stairwell temperature
      value_template: '{{ states.sensor.raspberrypisensors.attributes["temp_stairwell"] }}'
      device_class: temperature
      unit_of_measurement: '°C'

My question is: how can I assign these sensors to areas of the house (eg. Stairwell, Boiler room, Kitchen,. etc.). Sensors detected through integrations can be assigned to areas, but for template sensors I can’t find how to do it.

Thanks!

Restful sensors do not (yet) support a unique id. Thus they can not (yet) be assigned an area.

That’s a real shame… it would be super easy to add a unique ID from the yaml config.

1 Like

I was looking to also do this, searching I only found this topic of 2 years ago. Curious if this is still the case it cannot be done, if there is an option now to do this.

Yes the restful platform and integration both support a unique id now https://www.home-assistant.io/integrations/sensor.rest#unique_id

1 Like

Thanks for the response @tom_l ! Adding a Unique ID will allow one to set the zone (through the web interface)?

An ID that uniquely identifies this entity. This allows changing the name, icon and entity_id from the web interface.

Yes, that’s what the link I posted says.

1 Like

I wasn’t use about zone as it listed ‘name’, ‘icon’ and ‘entity_id’, but good to hear that :slight_smile: