Reading device property on Rule Machine and storing data

Hi!

I actually have two questions. if it feels inconvenient I can break my post in two:

Situation: I am creating a rule using Rule Machine. The trigger is when the door opens AND a motion sensor detected movement.

  1. Can I create a trigger that is true when more than one condition is true (i.e. create a AND statement)? Or should I use predicates for that?

  2. During my tests I am just trying to read the motion sensor and write down in a notification (for debugging purposes). However, I can't grasp any property of the motion sensor when I am creating an action to send notification to my phone. How do you do that? The only way I could find so far is creating a global variable and a rule for updating the variable every time the motion sensor changes state. Is there a less burocratic way to do that?

  3. Finally, other thing I would like to do is keeping a kind of counter (think of those classic signs "we are X days with no incidents"). So basically a value in a variable but I would like to display that information in a dashboard. Is there some kind of Virtual device that could help me with that? Also, is there a way to write down this info so I don't lose in case of power shortage?

Thanks a lot!

For question 1, this has spawned quite lengthy discussion in the past. You may want to think through and explain a bit more of what you are wanting to achieve. I expect you are wanting to use a predicate as you mentioned. Are you wanting to only trigger the rule if the door has been opened, or if it has been opened shortly before motion is detected? The answer to your AND question, no, think of the triggers as only OR statements, with the predicates allowing for pre-conditions that have to be true for the triggers to activate the rule.

For part 2, aside from the variable, the other option you have, due to the fact the motion attribute being essentially on or off, you could look into a conditional action that sends one notification if motion is active, and a different one when motion is inactive, or setup a separate rule that is triggered by a change in the motion sensor, again with the conditional action for the notifications. If that doesn't make sense, I'll see if I can create an example.

For three, can't say I've done this specifically, but maybe a variable that is updated each night or at sunrise, whatever suits, and see if there are options in RM for date calculations (I don't know if there is....). If there are, this would reduce the impact from power outages continuing to impact the result.

1 Like

Tks for the quick reply.

#1 basically what I want to do is try to guess if there is a person entering home or leaving home. I have a contact sensor at the door and a motion sensor close to it. When a person is leaving home the motion sensor will necessarily have been spotted it just before the door is open.
How would you use RM for solving that?

#2 have you ever tried webcore? Do you know if these things would be easier over there? I like RM but oftentimes I wish I could just do lines of code...

#3 it doesn't matter to me if the data is a date or a variable, my main issue is how I could display that in a dashboard (I was thinking maybe I could create a virtual thermometer or similar and set the temperature as the number I want?)
I also assume the global variables are reset when there is a power shortage, that's why I asked if there is some way to save the info somewhere.

I'll go in reverse order..... For #3, you can nominate variables in the setup for a dashboard, in the same way you nominate devices. I would have expected Global Vars to persist beyond a power outage..... One way to find out... So essentially I don't expect you will need to setup some kind of separate virtual device to store the result.

I haven't used webcore myself, but I believe there are plenty here that still do. I get being drawn to code. I use various visual tools for work and it somehow feels more comfortable to write code for many things... There's a couple of threads around for webcore if you wanted to post a question there, someone may be have some advice.

The reason for the OR (and previous lengthy discussions) is that the triggers for RM rules are essentially events, in almost all cases I would expect. So even if we think of motion and the door opening as happening at effectively the same time, even with different reporting patterns and just the processing of signals to the HE platform, the events are not going to fire at exactly the same time, so both situations can never really be true at exactly the same time. You can have a situation where one event fires and you wait for the other, or flick a switch to indicate a state and have that as a predicate, etc.

Reading back over you last post again, I think I / we may be over complicating things, could you not just have a trigger for the rule as being either motion or the door opening? Or are you wanting to use the order of the door and then motion or vice-versa as the indication of the direction the person is going, coming or going? If the latter.... I'll need to think about it, but there will be a way identify the order of things happening....

Hub variables do, indeed survive power outages.

As to webCoRE, quite a bit that can be done using it and some like it more than RM. I started over on ST so still my go to if I want a quick rule, but can usually find a way to do the same thing in RM. What attribute are you looking to pull into a notification?

Basic logic regardless of the tool used would be something like:

If Contact-Sensor open
   If Motion Active
       Notify ā€œPerson arrivingā€
   End-If
Else If Motion Active
   If Contact-Sensor open
      Notify ā€œPerson leavingā€
   End-If
End-If
2 Likes

The thing is that the motion sensor might be triggered if ppl just walk by the hallway, not opening the door. Likewise, if I just check the door being opened then I will have cases when a person is entering home, and that scenario does not convey to me.

I did a test as above and it worked! Can't tell how reliable it will be (for how long the motion sensor keeps marked as "active"? ). I am satisfied with that for now :slight_smile:

about #3: I am creating a dashboard using The Home Remote. I will check later if it can read hub variables, that will be awesome. Great to know that apparently hub variables values are possibly persistent. I will test that later as well!

1 Like

Tks @thebearmay
I really want to save some time to start digging into Webcore.
The code sample you shared is very aligned to how I solved it with RM!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.