[SOLVED-ALMOST] Basic Thermostat with Experimental Rules

Hello,

i am new to OPENHAB (2-3 months) - here is my project
i have used WEMOS D1 mini, some sensors and some relays to make a home thermostat.

now i want to use the EXPERIMENTAL RULE ENGINE to turn on and off the relay… when i press play (execute rule), it turns on and off… but the trigger i set i am not sure if it is good

here is the screenshot of my trigger -

can i use > or < in this state field to choose if it will be “< 22” and “> 23” to trigger the rule.?

for less than 22 degrees and more then 23 deegrees

thanks for your help

Yes but not in the trigger. That is what the “but only if…” section is for. Trigger the Rule on changes or updates to the temp Item. Then in the “but only if…” you will need to create two “item has a given state” conditions, one for the < 22 and the other for the > 23. That will prevent the Rule from actually running when the temp is between 22-23 degrees even when the trigger occurs.

can i leave the when EMPTY? and use only but only if?

pon, 4. velj 2019. u 21:42 Rich Koshak via openHAB Community bot@community.openhab.org napisao je:

actually… i will use TIME OF DAY in when for night setting and day setting… and will use but only if for temperature :slight_smile:
…i tried it… it wont allow to set a time period… only fixed time

pon, 4. velj 2019. u 21:42 Rich Koshak via openHAB Community bot@community.openhab.org napisao je:

UPDATE… i have 2 rules made - one for TURNING ON, on fore TURNING OF.

none of the rules do anything automaticly … only when i press te Play button… i dont know what i did wrong… here is the copy of the json file (that was generated automaticly with the experimental rule engine)

GASI - means TURN OF
PALI - means TURN ON
GUMB - means SWITCH
(all croatian)

{
“aefa5045-da94-4994-8d2f-08b6f8641502”: {
“class”: “org.eclipse.smarthome.automation.dto.RuleDTO”,
“value”: {
“triggers”: [
{
“id”: “3”,
“label”: “an item state is updated”,
“description”: “This triggers the rule if an item state is updated (even if it does not change).”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”
},
“type”: “core.ItemStateUpdateTrigger”
}
],
“conditions”: [
{
“inputs”: {},
“id”: “4”,
“label”: “an item has a given state”,
“description”: “Compares the item state with the given value”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”,
“state”: “23”,
“operator”: “\u003c”
},
“type”: “core.ItemStateCondition”
}
],
“actions”: [
{
“inputs”: {},
“id”: “2”,
“label”: “send a command”,
“description”: “Sends a command to a specified item.”,
“configuration”: {
“itemName”: “Gumb”,
“command”: “ON”
},
“type”: “core.ItemCommandAction”
}
],
“configuration”: {},
“configDescriptions”: [],
“uid”: “aefa5045-da94-4994-8d2f-08b6f8641502”,
“name”: “PALI”,
“tags”: [],
“visibility”: “VISIBLE”
}
},
“a196505d-12a5-4f08-ae72-64c26b6d4d64”: {
“class”: “org.eclipse.smarthome.automation.dto.RuleDTO”,
“value”: {
“triggers”: [
{
“id”: “3”,
“label”: “an item state is updated”,
“description”: “This triggers the rule if an item state is updated (even if it does not change).”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”
},
“type”: “core.ItemStateUpdateTrigger”
}
],
“conditions”: [
{
“inputs”: {},
“id”: “4”,
“label”: “an item has a given state”,
“description”: “Compares the item state with the given value”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”,
“state”: “23.5”,
“operator”: “\u003e”
},
“type”: “core.ItemStateCondition”
}
],
“actions”: [
{
“inputs”: {},
“id”: “2”,
“label”: “send a command”,
“description”: “Sends a command to a specified item.”,
“configuration”: {
“itemName”: “Gumb”,
“command”: “OFF”
},
“type”: “core.ItemCommandAction”
}
],
“configuration”: {},
“configDescriptions”: [],
“uid”: “a196505d-12a5-4f08-ae72-64c26b6d4d64”,
“name”: “Gasi”,
“tags”: [],
“visibility”: “VISIBLE”
}
}
}

It’s important to understand that the rule trigger has to be an event, a moment in time. When it happens, the rule runs.

You cannot use conditions like “when temperature is more than 5”, because that’s not an event, it’s not a single moment in time. When should the rule run?

We make things like that work by having say a “when temperature changed” trigger, and then checking to see if it is now more than 5 degrees, or between 10am and 11am, or whatever.

trigger is now state changes. it is the right item…

now i want to have in previous any state. and the state field also any state… what should i write inside. ?
and then i will decide in “BUT ONLY IF” wich temperature…

should i leave every field empty here?

No because the when is what actually triggers the Rule. Without it the Rule will never run.

Yes. The Rule will trigger any time the temperature changes. The but only if part will restrict the Rule from running only when the temp meets the give conditions, in your case the temp is < 22 and > 23.

UNFORTUNATLEY! no reaction. the switch doesent turn off.
i tried the TIME trigger… and that works… it turns off at a specific time…
but the state chage trigger doesent do nothing… and the temp changed from 23.2 - 23.4 and it should have triggerd the turn off… or? i set the update interval to 60 seconds… so it sends the mqtt data every 60 seconds

{
“aefa5045-da94-4994-8d2f-08b6f8641502”: {
“class”: “org.eclipse.smarthome.automation.dto.RuleDTO”,
“value”: {
“triggers”: [
{
“id”: “5”,
“label”: “an item state changes”,
“description”: “This triggers the rule if an item state has changed.”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”
},
“type”: “core.ItemStateChangeTrigger”
}
],
“conditions”: [
{
“inputs”: {},
“id”: “4”,
“label”: “an item has a given state”,
“description”: “Compares the item state with the given value”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”,
“state”: “22”,
“operator”: “\u003c”
},
“type”: “core.ItemStateCondition”
}
],
“actions”: [
{
“inputs”: {},
“id”: “2”,
“label”: “send a command”,
“description”: “Sends a command to a specified item.”,
“configuration”: {
“itemName”: “Gumb”,
“command”: “ON”
},
“type”: “core.ItemCommandAction”
}
],
“configuration”: {},
“configDescriptions”: [],
“uid”: “aefa5045-da94-4994-8d2f-08b6f8641502”,
“name”: “PALI”,
“tags”: [],
“visibility”: “VISIBLE”
}
},
“a196505d-12a5-4f08-ae72-64c26b6d4d64”: {
“class”: “org.eclipse.smarthome.automation.dto.RuleDTO”,
“value”: {
“triggers”: [
{
“id”: “5”,
“label”: “an item state changes”,
“description”: “This triggers the rule if an item state has changed.”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”
},
“type”: “core.ItemStateChangeTrigger”
}
],
“conditions”: [
{
“inputs”: {},
“id”: “4”,
“label”: “an item has a given state”,
“description”: “Compares the item state with the given value”,
“configuration”: {
“itemName”: “WemosD1_Dole_DHT22”,
“state”: “23”,
“operator”: “\u003e”
},
“type”: “core.ItemStateCondition”
}
],
“actions”: [
{
“inputs”: {},
“id”: “2”,
“label”: “send a command”,
“description”: “Sends a command to a specified item.”,
“configuration”: {
“itemName”: “Gumb”,
“command”: “OFF”
},
“type”: “core.ItemCommandAction”
}
],
“configuration”: {},
“configDescriptions”: [],
“uid”: “a196505d-12a5-4f08-ae72-64c26b6d4d64”,
“name”: “Gasi”,
“tags”: [],
“visibility”: “VISIBLE”
}
}
}

could this be the problem

the log shows also the temperature unit (°C)

should i add this in the but only condition? i will try

EUREKA! solved

i removed the DIMENSION in the item… and used a pure number in the condition “But only if”

and now IT WORKS!

now the question is… how to write the dimension in the state field?

for instance… “23:temperature” ist that right… or 23#temperature ?

can anybody direct me… in which browser do the DAY BUTTONS work

i tried explorer and chrome… and nothing :slight_smile:

i read your other posts about the rule engine… thank you for making it better… and trying to improve it. and explain it.
using the GUI will make openhab accesible to more people… and thats great…

also thank you for helping me… i have my thermostat doing basic automation.

i would like to use the DAY of the week rule… and add the dates manually in the JSON file.

this appears in the JSON file when i add the DAY OF THE WEEK rule… but the field which days it should be is not filled

{
“inputs”: {},
“id”: “6”,
“label”: “it is a certain day of the week”,
“description”: “checks for the current day of the week”,
“configuration”: {},
“type”: “timer.DayOfWeekCondition”
}

i dont know in which field to add it to… and what format they should be in :slight_smile:
under configuration?

I have no idea. It may not even be supported yet.

None. They are currently broken. I don’t know what is supposed to go in their either and as long as the UI is broken I don’t know how to discover the right format.