Anyone who can help me with a rule condition.
I need to understand how I update an Item when a given condition is meet.
I Need to update an Item when a value gets below a certain value and not updated again before it gets over a certain value.
Hope you can see what I mean?
which of the 2 examples below is closer to what you want to achieve?
It may be better for you to type up a draft rule so we can understand the concept.
You have a temperature sensor that reads the internal temp of your house and it has a
refreshInterval=10 (i.e. state updates with new reading every 10 secs)
Now, you want to trigger another Item that controls the boiler and turn it on if the temp will go below 20 and off if the temp will goes above 22.
Same temp sensor as above.
Now, you want to update another proxy Item with certain values based on the results of the first one.
e.g if temp goes below 20 then update proxy with String “Cold”, else between 20 and 22 update with String “Moderate”, else with “Hot”
edit: You cannot control the updates of the temp sensor Item itself based on such conditions since the Item will get “raw” updates from the binding. Unless of course you can implement such logic in the endpoint device itself.
When it gets below 20 I only want it to update the item one time, as long it stays under 20 no updates are wanted.
Above 22 I want it to update the Item with new values.
Reading your requirement it sounds you do need an item that does NOT get all updates from a sensor. In this case you would need one item (linked to the sensor, showing the correct value all the time, however this item is probably not shown on a sitemap) and another item, which gets ist updates via your rule.
The rule should be triggered on each change of the linked item. In the rule use a global flag, which gets set TRUE when the value changes below 20 and set to FALSE if above 22. Updates to the unlinked items are sent whenever the flag is FALSE.
Here is a code snippet that I use to update up my ecobee thermostat if it’s 45F degrees or warmer outside and doesn’t update the thermostat again until it drops below 45…
Item eb_out_temp received update
val otemp = eb_out_temp.state
if (otemp >= 45 && !override_active)
override_active = true
sendBroadcastNotification("Start daytime heat boost")
desiredCoolTemp = new DecimalType(80)
desiredHeatTemp = new DecimalType(71)
ecobeeSetHold("4xxxxxxxxxxx", desiredCoolTemp, desiredHeatTemp, null, null, null, null, null)
if (otemp < 45 && override_active)
sendBroadcastNotification("Stop daytime heat boost")
override_active = false
I’ll try your suggestion using flag.
I’ll see if I can adapt your solution - Thanks
I wrote a Design Pattern for this. Design Pattern: Event Limit
I need to update it a little so it matches the format of the other DPs but it is still accurate. It basically does what oupus suggested using a flag and what mikmartin’s code does, but the more detailed text description might be useful.