Add Manual Sensor without Overriding Existing Sensors

As the title has it, I recently added a sensor to my config.yaml file manually. However, I found that when I did this, my Pico remotes stopped working (they are sensors). It appears there can only be 1 sensor section in a config and since I did not define my Picos, they stopped working.

What I would like to do is manually add sensors without having to re-define any of the existing sensors. I’m not sure how to do that.


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: template
    sensors:
      bedroom_light_brightness:
      friendly_name: "Master Bedroom Brightness"
      value_template: "{{ states.light.bedroom.attributes.brightness }}"

Like this:

sensor:
  - platform: template
    sensors:
      bedroom_light_brightness:
        friendly_name: "Master Bedroom Brightness"
        value_template: "{{ state_attr('light.bedroom','brightness') }}"

      another_one:
        friendly_name: "Another Sensor"
        value_template: "{{ states('sensor.foobar') }}"

Alternatively you can also do this:

sensor:
  - platform: template
    sensors:
      bedroom_light_brightness:
        friendly_name: "Master Bedroom Brightness"
        value_template: "{{ state_attr('light.bedroom','brightness') }}"

  - platform: template
    sensors:
      another_one:
        friendly_name: "Another Sensor"
        value_template: "{{ states('sensor.foobar') }}"

Note I have changed your templates to use state_attr(). This is important. Scroll down to see the warning box here: Templating - Home Assistant

Another point is that you should be using the new template format for new sensors. See: Template - Home Assistant

Using the example above it would be:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

template:
  - sensor:
      - name: "Master Bedroom Brightness"
        state: "{{ state_attr('light.bedroom','brightness') }}"

  - sensor:
      - name: "Another Sensor"
        state: "{{ states('sensor.foobar') }}"
1 Like