I think “had changed” has replaced this.
But I have a contact sensor that “tickles”. The solution would be is there was a possibillity to set a delay for a second after the trigger?
I beth there is better solutions that I don’t know about.
Can you clarify what problem you are trying to solve?
Perhaps it would help to share a screenshot of your rule as you currently have it configured along with a description of what you are trying to accomplish and which part of it isn’t working.
Yes of cause.
Case: When my gate is totally closed, a contact sensor should pick that up. But it sends multiple signals within a second, and stays “open” or “Close”, depend on the position of the gate. (see log screenshot below)
Tried to fix with a Rule.
Trying to show the sensor direct in a Tile would be best, but be cause of the tickle it is unstable too. Show an open gate when it is really open.
Edit:
I open the gate at 23:22:39, closed it, and it stayed secure and closed at 23:22:54
I wonder if you could solve this by adjusting the contact sensor on the gate. I’ve had to reposition several of my gate sensors since the gates wobble when they latch closed and can trigger multiple open/close events.
Hi, @Wet.Blanket
You might sit on the best solution. I will try that.
I have a backup solution with using a Fibaro Smart Impant and a traditional micro switch.
I have a feeling the Aqara magnet switch is very possition sensitiv, and gives this signals. The two parts are not rock solid.
Thank you for the answare
Vidar
You would want to use a State Stays trigger for this rather than an IF Condition.
The way the rule currently reads, the condition would never be true as the rule would be triggered by the contact
sensor updating, then it would immediately check to see if the sensor had stayed open for the past 1 second.
It wouldn’t be possible for the sensor to have ‘stayed’ a value for a duration of time immediately after it updated.
Instead, you would want to use the State Stays on the trigger directly. That way the rule would only trigger once the attribute had stayed a value for a period of time.
–
From there, I would recommend using a Context Variable for grabbing the triggering event value ($context.event.value
). By using a context variable, you are able to access the value that was used to trigger the rule – if you instead used a device condition, it has to reach out to your smart home hub to ask for the current value, so it’s a bit slower and not quite as efficient.
The rule flow could even be simplified to a single “Set Variable $closedGate
value using expression” block like:
equalText($context.event.value, "closed")
When combined with a state stays trigger, this reads like:
If the triggering event value stayed ‘closed’, set $YourVariable to true, otherwise set it to false
My skill level == “Teris”
To clarify: $closedGate
is in this new test called $StatusGate
If i understand right I need 2 triggers, one for Gate “Stays closes” and one for “Stays open”
I set the time for 5 seconds. (Logg show 3 updates in the same timestamp)
Second… I tried to set variable using Expression, this is where my head got full. (Is the "closed"
the new value in $GateStatus
or a new temporally variable?)
Here I got “open” and “closed” value in $GateStatus
by Set my $GateStatus
to Variable $context.event.value
I need to read about this language. Book suggestions are received with huge gratefulness.
That sounds like the right configuration for the triggers, but the log entries at the same time doesn’t seem right.
If you want to share the Rule ID, I would be happy to take a closer look.
Expression and static “closed” string
In my example with the expression, it was a fixed string value. In your original example, your $closedGate
looked like it was a boolean since in your original rule you were setting it to True or False, so I was mirroring that.
If you just wanted to copy the raw open
or closed
value over, you could just have a single Set Variable block in your rule flow (no IF Condition needed at all).
Set Variable $StatusGate
value using $context.event.value
value
Expression to convert text to true/false
The reason I used an expression in my original example was to convert the closed
or open
value to a true
or false
value.
I was mirroring what you were doing in your original example with the IF Condition where you were mapping open
or closed
to your Boolean variable.
You can find an introduction to expressions and other documentation on our help site:
Rule Id
ehn3vi5CVjD6I4j8T191
Now i realy have some reading to do.
(Guess mecanic, and train driver was not optimal background🫢 but i am learning alot)
Thanks for sharing the Rule ID. I’ll have to do a deeper analysis as I don’t see anything obvious at first glance.
Looking at the logs you shared, it looks like all three events were received within 150~250ms which is quite fast.
Value | Raw Event |
---|---|
open |
2024-09-03T20:00:38.957Z |
closed |
2024-09-03T20:00:39.016Z |
open |
2024-09-03T20:00:39.158Z |
Yeah, that’s very strange.
Notised in a gate-test this morning. I made a “tickle” again. Then flipped the values.
Studying the log, “usually” the 3 Set values is ex. “closed” “closed” “open”, but this time it was “closed” “open” “closed”, and it resulted in a flipped report.
But if it’s take too much time debugging this, I can try mount the microswitch and Smart Implant. But I guess I will find an other challenge then (3 stage reporting, close, between, and open. using 2 microswitches)
I will spend some time now reading more this language. Maybe some basic programming too(what is it called?)
The expression syntax isn’t a full programming language. It’s a set of operators for comparisons (eg. >
, <
, !=
, etc), and math (+
, -
, *
, /
), and a set of methods that we’ve put together.
The documentation is available on our help site starting from this main article:
That article provides an introduction to what expressions do, how you can use them, basic mathematic operators, and using variables. The article also links to other reference articles that have more details on various methods that are available:
- General Functions in Rule Expressions
- Date Functions in Rule Expressions
- Variable Introduction and Overview
While it’s a relatively primitive set of functions and syntax compared to a full programming language, it’s a very powerful tool when you need more complex logic in your rules!
I’m focused on shipping a fairly large update to our email system at the moment and trying to get it released before I go on holiday with my wife later this month – but I’ll work on taking a closer look at the state-stays trigger issue in between things. If I can reproduce it with my Homey setup, that should make it easier for me to identify what’s going on, so that will likely be my next troubleshooting step.
I agree that trying to fix it properly with the underlying sensor is the ideal approach, but I’m still curious why the state-stays trigger isn’t working as expected with these events and what tweaks we might be able to make to better accommodate that.
For sure you deserve a holiday with you wife.
I Just got a mail from a skilful guy called Josh.
In that mail I saw “light”, about equalText…
I think I understand, how to rebuild this rule, to the same structure as my “Hjemme”/“borte” rule. No If’s, only equalText.
Then we will se about the trigger as time and holiday go.
I made a test.
Just to see behaviour.
I made a Dashboard, contents 5 tiles.
tile 1 (from left) - triggers open/stop/close the gate
tile 2 a tile reading the sensor direct, shows the “tickle”
tile 3 using $context.event.value with 5 second delay In the trigger
tile 4 using IF… also 5 sec.
tile 5 (below the others) a camera showing is the gate is fully closed (confusing when I get faulty readings )
kinda bil file for a min of video, sorry for that:
https://vidark.no/gaterecording/gatetrouble.mov