The trigger is started but the condition evaluated to false when when someone arrived so the poor thing was without a light in the kitchen.
(ah well, it was about noon so not really a problem )
I hope someone can explain me my problem with this:
Why is my value_template evaluated to false when the count changes from “3” to “4” ?
I can imagine many reasons like: the from_state does not exist …
Is there a way to debug this? (like finding the from_state)
What should I change to get it working? (preferably with a little explanation or a pointer to some doc that explains this a bit)
thanks for your reply.
Only thing is that I think that only fires when changing from 0 to anything above 0. I also want it to fire when someone already is at home.
thanks for your replay @busman,
I want it to fire every time someone arrives at home. Not only for the first one but also for any additional person that arrives.
thanks again for your reply @Arh
but given the dynamics in my household that would require adding and deleting triggers over and over again. The idea I found using that template can’t be very wrong. So I was hoping to correct what I did wrong, keeping the trigger as intended. Fire when anyone arrives at home. The persons_at_home helper template counts the number of persons (well, actually their devices that are tracked) pretty good. When that value increases I want an action. I just don’t understand my error there. Is there a way to debug this with more detail?
Ah, sorry. I have the same automation but I assume if someone is already home no need to turn on the light.
Interesting. Is there a risk that your template sensor might pick up states you don’t want to track?
Your approach seems kind of how I’d do it. Or if it is something you want to use in a number of automations maybe have one automation that has the specific people to track and then fire an event that other automations can trigger on?
No idea about picking up other events. How can I verify that? When I look at the sensor values I see a history with the expected counts. It also shows who triggered the increment or decrement of the value.
It’s just the template trigger that - in my opinion - should trigger true when an increment is done because someone arrived.
It must be something very simple that I overlooked.
Doesn’t the automation trace show why it is not running as expected?
Your template counts the number of device_trackers that are home, right? That what zone.home does, so you don’t really need that. (And your template might need to deal with unavailable, too.)
I don’t know, this works for me using a helper:
alias: Person increased
description: ""
triggers:
- trigger: state
entity_id:
- input_number.person_count
conditions:
- condition: template
value_template: "{{ trigger.from_state.state|int(0) < trigger.to_state.state|int(0) }}"
actions:
- action: persistent_notification.create
metadata: {}
data:
message: Home
mode: single
It looks very similar. Your helper is input_number.person_count?
Can you show the yaml code?
When I try to create a template helper with zone.home, I get ‘zone’ undefined.
Shows the number of persons instead of the number of trackers. Now I defined the helper as a numeric template helper. What I had showed as character type and not as numbers.
Testing in progress.
Isn’t that what you want? You assign device trackers to people (typically a Companion App phone) and set a home zone and zone.home tells you how many are in that zone.
Not following that. All states are strings, which is why you are converting to int(0) when doing a numeric comparison, as I’m sure you know.
The problem seems to be just the condition is always returning false?
In this case it doesn’t really matter if I count trackers or people. If the number of either increases it will be because someone arrives (assuming the trackers don’t travel alone)
So yes, to false that is returned is my problem. When the count goes from ‘3’ to ‘4’ I hope that the ‘3’ is in the trigger from state and the ‘4’ in the trigger to state. If so, than I also hope that 4 > 3 returns true.
so much hassle for such a basic thing.
If you use NodeRed or you are willing to look at it, it’s a matter of a single single node. I can provide you with an example.