#Delay Occupancy or Presence

1 messages ยท Page 1 of 1 (latest)

shrewd stone
#

Hi there,

I dont understand the templating at all.

The tutorial states that i can use "delay_on" or "delay_off" but it doesnt work.
I also dont get the whole template thingy when trying to create an custom template. I dont have the option to just copy paste the expamle templates.

Instead i get this .. "weird template manager", which i dont understand what to input where.

What i want to do?

I got an ESP32-S3-Box-3 with a Radar Dock that reports Occupancy every second.
I'd like to create an Presence Entity, that gets the binary sensor, and delay its state.
So when an Occupancy is detected there is a Presence for couple Minutes.

unkempt smelt
#

If you want delay_on/delay_off you cannot use the UI, you must create the template manually in a configuration.yaml file

shrewd stone
#

Whats the weird template UI then? Where does it come from?
And more importantly: Why isnt it working there? And with that, why is it there, when its not working?

#

To clarify my confusion: The Tutorials on the Forum, and the Reality are a bit far apart.

unkempt smelt
#

The template UI is for simple templates. If you need more complex options than are provided there, then you have to go to yaml.

shrewd stone
#

so to be sure.. u want me to put the code in here?

shrewd stone
#

thats the only options.
would be nice to get an: "create custom template" option.

#

but still it doesnt work as intended:

Im using the Dev Tools Template Tester (if i understood this thing right)

#

`# Sourcecode by vdbrink.github.io

configuration.yaml

template:

  • binary_sensor:
    • name: "Presence S3 Box 3"
      unique_id: presence_s3_box3
      state:
      {{ is_state("binary_sensor.esp32_s3box_3_presence_detect", "off")
      }}
      device_class: presence
      delay_on:
      seconds: 5`
unkempt smelt
#

What does Check Configuration button say in developer-tools/yaml?

shrewd stone
#

I didnt input it there yet, bc i dont get the delay in the Tester.

unkempt smelt
#

You don't input anything there, it tells you if the code you put in configuration.yaml is valid.

#
- state:
+ state: >

I think you are missing this > character after state

#
template:
  - binary_sensor:
      - name: "Presence S3 Box 3"
        unique_id: presence_s3_box3
        state: >
         {{ is_state("binary_sensor.esp32_s3box_3_presence_detect", "off")
         }}
        device_class: presence
        delay_on:
          seconds: 5

And some indentation issues.

shrewd stone
#

what is this dev tool then for?
on the right side the state doesnt change accordingly to the delay.

#

it changes instantly like the original sensor.

unkempt smelt
#

Template devtool is for evaluating the things in between {{ }}

#

If you're making template entities that's something else.

shrewd stone
#

Huh? I dont understand.

#

Like just the general understanding and where my confusion comes from:

  1. There is a Template Testing Tool.
  2. Its not working to test Templates.
unkempt smelt
#

The term template is a bit overloaded, yes.

#

In HA a template can mean a jinja expression wrapped in "{{ }}" that is evaluated to return some string.

#

There are also entities, called template entities, which derive those states from those expressions.

#

The template testing tool is for testing the former.

#

If you want to create a template entity, I am telling you how to do it.

#

Your code looks almost correct, so next you need to put it in your configuration.yaml, run the check configuration, and if it is good, then you can restart HA and hopefully have your template working.

shrewd stone
#

Holy shit, that sounds hella overloaded to restart the whole thing, just to get a template working o.O
But I'll try it.

unkempt smelt
#

Restart is needed the first time you add a new integration to yaml (template:).
Adding more template entities in the future you can just click the reload templates button.

shrewd stone
#

Okay that seems to work, but now i created just an new entity. How do i link this entity to the Device? The Helper has this nice little feature, but in the Template Documentation i cannot find anything about linking.

#

Thanks for the help so far.
This different and not clear communicated options and UI drove me crazy.

unkempt smelt
#

How do i link this entity to the Device?
Unfortunately not possible.

#

UI only can do it. Some technical reason about how the config entries work, not sure.

shrewd stone
unkempt smelt
#

Linking to devices is a very new feature. Was only added to the UI entries.

#

Maybe someday will change, I dunno.

#

Its not really necessary though.

#

Just cosmetic.

shrewd stone
#

Its not a cosmetic feature, to add an entity which is dependend on an other entity from that device, to that same device.

#

like what i try to do: presence detector is changing its state secondly
but my change with delay shows the same entity with my own customization, right under the real one

#

like that:
"Occupancy" is the live secondly changing sensor.
"Presence 3 Minutes" is the 3 Minute delayed sensor.

Now i can connect some devices or entitys, which can automatically be turned off or on when for 3 Minutes no movement is detected. FINALLY!!!
Damn that was hard tbh.

#

Made the yaml template with the delay.
And linked the new yaml entity with the helper now.
Still super annoying and overcomplicated method of doing things.

shrewd stone
#

Funny: now that I've set it up I get this option presented ๐Ÿ˜‚๐Ÿ˜‚
Wait after last detection ๐Ÿ˜‚๐Ÿ˜‚
Exactly what I wanted