Rules: difference between status and change

Hi all,
I want to implement 2 different rules (with different actions of course) for the following;
evening

  • I am at home (my alarm has status inactive)
    and
  • it becomes dark outside (reading of brightnes drops below treshhold (=change))
    morning
  • I am waking up (I uncharge the alarm (=change)
    and
  • it is still dark outstide (brightness is still lower then treshhold)

I have sensors defined for brightnes and alarm and they work fine. I now have the rule for the evening, which works perfect, but it will also fire, when I uncharge the alarm before dawn.
rule “alarm aanwezig inactief licht”
when
Event(source == “virtual_sensor_aanw”, value == “0”)
Event(source == “read brightness”, value < 700.0)
then
execute.command(“action evening”);
end

``

So I need to distinguish between “status” and “change” for these sensors. I presumably thought that “Event” in the rules would make sure it is only fired at a change of the (status of) the sensor.

Of course, I could add timing conditions somehow, but there must be a better and simplier way, right?

Thanks for any suggestion

Hi,

I’m not sure if I understand your question. What exactly do you mean by ‘status’ and ‘change’? Especially, how you refer to it in the rules?

Anyway, a rule is triggered only when value has changed. There is no trigger when value stays the same. However, because you have two Event() on the RHS then the rule will trigger when either value changes.

Please describe once more what you want to achieve, what you did and what is going wrong? Right now, your description is a bit dense for me :wink:

Kind regards,

Michal

ok, I will try to clarify what s happening and what I want.
Situation at moment x
Alarm is not charged. So sensor alarm value = 0, and it stays 0 the whole time. + At the same time, there is abondant daylight, so the action is not triggered.
(source == "virtual_sensor_aanw", value == "0") is true (``source == "read brightness", value < 700.0) is false => do nothing
Situation at moment x+1
Alarm is not charged. So sensor alarm value = 0, and it stays 0 the whole time. + Suddenly daylight drops below treshhold and action is fired.
(source == "virtual_sensor_aanw", value == "0") is true (``source == "read brightness", value < 700.0) **becomes** true => fire action1
So I have two times “Event” in my rule, but only the second condition was changed at the moment of firing the rule.
But, as I said, this is actually doing what I want to achive for the evening action. Now the problem is that this rule will also fire in the morning (or uncharging the alarm during night), where I would like another action.
This is how “morning” should be identified somehow in a rule;
Situation at moment x
Alarm is charged. So sensor alarm value = 1, and it stays 0 the whole time. + At the same time, it is dark outside and brightnes stays below treshhold.
(source == "virtual_sensor_aanw", value == "0") is false + (``source == "read brightness", value < 700.0) is true => do nothing
Situation at moment x+1
I uncharge the alarm. So sensor alarm value becomes “0”. + At the same time, it is dark outside and brightnes stays below treshhold.
(source == "virtual_sensor_aanw", value == "0") **becomes** true + ``(source == "read brightness", value < 700.0) is true => fire action2

So the rule in my first post is now fired for both scenarios. Is there another syntax I should use instead of “Event” for one of the two conditions to differentiate between “Becoming true” vs “Being true”?

I hope this clarifies a bit?

I’m afraid that you want to do something that isn’t feasible. You want to prevent a rule from firing when one of inputs (alarm) is changing. This can be done, but you have another problem, the Event(source == “read brightness”, value < 700.0) would fire at each update of the sensor “read brightness” in case it is less than 700. Each changing value would trigger it. IMHO, you need to rethink the logic and first write it down in plain English. Later we can see how to translate is to rules.