10
Assistance creating a sensor (lemmy.thewooskeys.com)
submitted 7 months ago* (last edited 7 months ago) by mike_wooskey@lemmy.thewooskeys.com to c/homeassistant@lemmy.world

Hi.

This works fine in the template editor:

{% if states('sensor.apollo_mtr_1_cca750_presence_target_count') | int > 0 %}
  Detected
{% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_1_occupancy', 'on') %}
  Detected
{% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_2_occupancy', 'on') %}
  Detected
{% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_3_occupancy', 'on') %}
  Detected
{% else %}
  Not Detected
{% endif %}

But when I try to create a binary_sensory from it in configuration.yaml, I get "'binary_sensor' is undefined":

template:
  - binary_sensor:
    - name: "Lounge Presence"
      state: >-
        {% if states('sensor.apollo_mtr_1_cca750_presence_target_count') | int > 0 %}
          Detected
        {% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_1_occupancy', 'on') %}
          Detected
        {% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_2_occupancy', 'on') %}
          Detected
        {% elif is_state('binary_sensor.apollo_msr_2_c7bfe8_radar_zone_3_occupancy', 'on') %}
          Detected
        {% else %}
          Not Detected
        {% endif %}
      device_class: presence

I'm probably using incorrect syntax or something. Can anyone help me with this?

you are viewing a single comment's thread
view the rest of the comments
[-] mike_wooskey@lemmy.thewooskeys.com 1 points 7 months ago

Thanks for the suggsetion @Matt The Horwood.

It looks like a "Combine the state of several sensors" or a "Group" helper only allow you to combine sensors of the same type.

I created a binary sensor from a template using the helper, but it also returns "'binary_sensor' is undefined" when I try to access its value in the template editor with {{ states(binary_sensor.lounge_presence) }}

this post was submitted on 01 Nov 2024
10 points (100.0% liked)

homeassistant

14848 readers
12 users here now

Home Assistant is open source home automation that puts local control and privacy first.
Powered by a worldwide community of tinkerers and DIY enthusiasts.

Home Assistant can be self-installed on ProxMox, Raspberry Pi, or even purchased pre-installed: Home Assistant: Installation

Discussion of Home-Assistant adjacent topics is absolutely fine, within reason.
If you're not sure, DM @GreatAlbatross@feddit.uk

founded 2 years ago
MODERATORS