Motion sensor template not working

I’ve started using a sensor template so they all report the same way, and it’s worked for 5 out of 7 of my motion sensors.

Five of my sensors are Zooz 4-in-1’s, the two problem ones are a SmartThings first-gen, and the other is a BeSense ceiling sensor.

They aren’t working in the template. I believe it’s an issue with the float. The states they both report are “off” and “on”, but off and on do not work in the template tab under developer tools. “false” and “true” work, but the sensor does not report anything with that setting.

The top two posted below are the ones that do not work, the others below are all the ones that do work.

Anyone have any advice?

- platform: template
  sensors:
    motion_garage:
      friendly_name: "Garage Motion"
      device_class: motion
      value_template: "{{ states('binary_sensor.motion_garage_old')|float > off }}"

- platform: template
  sensors:
    motion_wyatts_bedroom:
      friendly_name: "Wyatt's Bedroom Motion"
      device_class: motion
      value_template: "{{ states('binary_sensor.motion_wyatts_room_old')|float > off }}"
- platform: template
  sensors:
    motion_entryway:
      friendly_name: "Entryway Motion"
      device_class: motion
      value_template: "{{ states('sensor.entryway_burglar')|float > 0 }}" 
        
- platform: template
  sensors:
    motion_kitchen:
      friendly_name: "Kitchen Motion"
      device_class: motion
      value_template: "{{ states('sensor.motion_kitchen_burglar')|float > 0 }}"

- platform: template
  sensors:
    motion_lanai:
      friendly_name: "Lanai Motion"
      device_class: motion
      value_template: "{{ states('sensor.burglar_lanai')|float > 0 }}"

- platform: template
  sensors:
    motion_living_room:
      friendly_name: "Living Room Motion"
      device_class: motion
      value_template: "{{ states('sensor.motion_livingroom_burglar')|float > 0 }}"

Look here for some help

1 Like

What is the purpose of making the first two templates? The entities are already binary sensors, do you want them to appear as motion sensors in the UI? If so, you don’t need to create an entirely new sensor, just customize their device_class with motion.

1 Like

What is this template attempting to accomplish?

      value_template: "{{ states('binary_sensor.motion_garage_old')|float > off }}"

A binary_sensor reports on and off so why is this template converting those states into a floating point number and then checking if this number is greater than off?

1 Like

I want all of them to report the same on the front end, here’s an example. I’d like for the bottom sensor in the screenshot, to appear like the top. They are already set to motion.

image

The last time I made the templates was for my zooz sensors, because the binary sensor for the Zooz devices does not work in HA, so I used the template to use the burglar instead.

I’m sure I’m doing it totally wrong, last time I just found a template and copy and pasted and it worked. I’ve been reading about it but do not see what I’m doing wrong.

Did your try freshcoast’s suggestion to customize the Zooz binary_sensor’s device_class? Doing so obviates the need for creating a Template Binary Sensor.

If for some strange reason that fails to work, then the Template Binary Sensors you’ve created need simpler templates. They only need to report the state of the associated Zooz binary_sensor. For example:

      value_template: "{{ is_state('binary_sensor.motion_wyatts_room_old', 'on') }}"

EDIT
Corrected the template because it should report true or false as per the documentation.

The Zooz sensors are the ones working, the ones I’m trying to change are the “binary_sensor.motion_garage_old” and “binary_sensor.motion_wyatts_room_old” binary sensors.

OK, I got the brand name backwards but everything else still applies. Use customization or the template I suggested.

Those are already setup as motion devices.

image

image

I’ll try your suggestion with the updated template.

It’s getting a little confusing here, but you’re supposed to be customizing the binary_sensor.motion_garage_old and binary_sensor.motion_wyatts_room_old sensors with device class. Are those the same sensors in the screenshot?

You know what, you’re correct. I was posting screenshots of my template sensor, instead of the physical sensor. I was able to change it’s class now. Thatnks a ton for all the help!

“That’s a bingo!”