I fixed the code. It now runs without an error message.
However, the status of the Wiser thermostat does not change.
var QuantityType = Java.type("org.openhab.core.library.types.QuantityType");
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
var ZonedDateTime = Java.type("java.time.ZonedDateTime");
// Der Wert, den du senden möchtest
var setPointValue = new QuantityType("22 °C");
// Log-Ausgabe des Wertes
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.core.automation.examples");
logger.info("a77476452e -SetPoint Value: " + setPointValue.toString());
// Senden des Wertes als QuantityType an das Item "WiserRoomFlurunten_SetPoint"
ScriptExecution.createTimer(ZonedDateTime.now(), function() {
events.sendCommand("Wiser_Thermostat__Flur_unten_Set_Point", setPointValue.toString());
});
What binding are you using for integration of your Wiser Thermostat in OpenHab? Zigbee, Deconz or MQTT? And how did you configure your item? Usually I would expect a number as a command. The script you posted seems to send a string. As Rich already said, posting your logs would be useful.
Ok, I understand, your Wiser Thermostats are not directly connected to OpenHab. You are controlling the things through a Wiser Bridge.
According to the Wiser binding docs the above item has to be configured as Number:Temperature. Make sure it is configured correctly and that you can change the temperature manually on the item widget page.
Your Aquara item needs to be configured as Contact with Category Window. Make sure that the state is updated accordingly when opened and closed.
Then just create a simple rule in OpenHab with with the rule tab (you need no script for that):
When Item NAME_OF_YOUR_WINDOW_CONTACT_HERE changed to OPEN
Then send command 10 to WiserRoomFlurunten_SetPoint
thank you very much for your tips.they have helped me a lot!!!
I can now successfully access WiserRooms.
var QuantityType = Java.type("org.openhab.core.library.types.QuantityType");
// Der Wert, den du senden möchtest
var setPointValue = new QuantityType("5 °C");
// Log-Ausgabe des Wertes
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.core.automation.examples");
logger.info("a77476452e -SetPoint Value: " + setPointValue.toString());
// Senden des Wertes 0,1 h an das Item "WiserRoom__Flur_unten_Boost_Duration"
items.WiserRoom__Wohn__Esszimmer_Boost_Duration.sendCommand(0.1);
// Senden des Wertes als QuantityType an das Item "WiserRoomWohnEsszimmer_SetPoint"
items.WiserRoomWohnEsszimmer_SetPoint.sendCommand(setPointValue)
The Gamechange was to use the Wiserroom instead of the thermostat itself.
Similarly, this is not necessary and you should either use console.
Replace with
console.loggerName = "org.openhab.core.automation.examples"; // changing the name of the logger is optional
console.info("a77476452e -SetPoint Value: " + setPointValue);
For close put all three Items into a Group with an aggregation function “all closed else open”. Trigger your rule using this Group Item changed state to closed.
The second condition would only be satisfied when the Setpoint == 5 °C.
In the future, please click the code tab and paste the text you find there instead of screen shots. Use code fences.
```
code goes here
```
It seems you have all the parts of the rule confused.
When
These are the events that happen to cause the rule to run, the trigger. In your text that is “IF Setpoint changed and window is open”. I would expect the rule to be triggered by both the Setpoint Item and the Window Item (the window can open after the setpoint is changed, right?)
Then
This is what to do when the rule runs and the conditions are all true. In your text version of the rule this should be something along the lines of “send command to Item WiserRoomWohnEsszimmer_SetPoint to 5 °C”. I can’t tell what your action does because this is just a screen shot. You don’t need a Script Action to do this though.
But only if
These are all the conditions that must be true for the rule to run the actions (i.e. the stuff under Then) when the rule triggers (see When). In your text that’s “Window is open” so I would expect to see the window Item listed there and nothing else. You have no other conditions in your text description of what you want the rule to do.
So it should be:
When
item WiserRoomWohnEsszimmer_SetPoint changed
item EG_KH_WindowSensor_f416_Open__Close changed to OPEN
Then
send command to item WiserRoomWohnEsszimmer_SetPoint to 5 °C
But only if
EG_KH_WindowSensor_f416_Open__Close = OPEN
WiserRoomWohnEsszimmer_SetPoint != 5 °C
The last condition is to avoid running the rule again when it’s commanded to 5 °C or it’s already 5 °C.
OK, so it’s the Window sensor condition that is condition 2. So I guess the window isn’t open? What is saying it’s unsatisfied? Normally it doesn’t log that out.