Detect Open Window (aqara) - Reduce Temperature by Wiser

Hello,

I would like to reduce the set temperature of my Wiser thermostats via my Aqara window sensors.

Open - Reduce the set temperature to the minimum
Close - Booster - 15 min with the same set temperature (open)

The problem is mainly in the temperature format.

Can anyone help me?

Probably not without seeing what you’ve tried.

Use code fences

```
code goes here
```

There is like half a dozen different ways to implement what you’ve described. Without knowing which of those you’ve tried :man_shrugging: .

Sorry for the late response. I was ill.

I just tried it with “Blockly”

{3DD6CA31-AB31-4BF1-AD93-16B639E2C70D}

Automatic generate code

events.sendCommand('WiserRoomFlurunten_SetPoint', 10);

What triggers’s this rule?

How are the relevant Items configured?

Do you see errors in the logs?

You got to give us something to work with here.

Hello,

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());
});

This is Nashorn JS? What version of OH are you running?

Logs?

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.

I use the binding DraytonWiser Binding.

I have configured the thing via the web-interface.

Autogen code

UID: draytonwiser:itrv:376ff32ac7:90FD9FFFFEB30652
label: Wiser Thermostat - Flur unten
thingTypeUID: draytonwiser:itrv
configuration:
  serialNumber: 90FD9FFFFEB30652
bridgeUID: draytonwiser:heathub:376ff32ac7
channels:
  - id: currentTemperature
    channelTypeUID: draytonwiser:currentTemperature-channel
    label: Temperature
    description: Current temperature
    configuration: {}
  - id: currentSetPoint
    channelTypeUID: draytonwiser:currentSetPoint-channel
    label: Set Point
    description: Current set point
    configuration: {}
  - id: currentDemand
    channelTypeUID: draytonwiser:demandPercent-channel
    label: Current Heat Demand
    description: Current heat demand in %
    configuration: {}
  - id: currentBatteryVoltage
    channelTypeUID: draytonwiser:batteryVoltage-channel
    label: Battery Voltage
    description: Current Battery Voltage for the device
    configuration: {}
  - id: currentBatteryLevel
    channelTypeUID: system:battery-level
    label: Batterieladung
    configuration: {}
  - id: currentWiserBatteryLevel
    channelTypeUID: draytonwiser:wiserBatteryLevel-channel
    label: Battery Level (Wiser)
    description: Current Battery Level for the device
    configuration: {}
  - id: currentSignalLQI
    channelTypeUID: draytonwiser:signalLQI-channel
    label: Signal LQI
    description: The reported network signal LQI
    configuration: {}
  - id: currentSignalStrength
    channelTypeUID: system:signal-strength
    label: Signalstärke
    configuration: {}
  - id: currentWiserSignalStrength
    channelTypeUID: draytonwiser:wiserSignalStrength-channel
    label: Signal Strength (Wiser)
    description: The reported network signal strength
    configuration: {}
  - id: zigbeeConnected
    channelTypeUID: draytonwiser:zigbeeConnected-channel
    label: Device Connected
    description: Is the device still connected to the ZigBee network
    configuration: {}
  - id: deviceLocked
    channelTypeUID: draytonwiser:deviceLocked-channel
    label: Device Locked
    description: Has the device been locked to prevent local changes
    configuration: {}
  - id: currentSignalRSSI
    channelTypeUID: draytonwiser:signalRSSI-channel
    label: Signal RSSI
    description: The reported network signal RSSI
    configuration: {}

Log on manual start of the script.

Time Level Source Data
07:06:14 DEBUG org.openhab.core.io.monitor.internal.metrics.RuleMetric Rule a77476452e RUNNING - updating metric.
07:06:14 DEBUG org.openhab.core.automation.module.script.internal.handler.AbstractScriptModuleHandler Executing pre-compiled script of rule with UID ‘a77476452e’
07:06:14 INFO org.openhab.core.automation.examples a77476452e -SetPoint Value: 22 °C
07:06:14 DEBUG org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine Lock released.
07:06:14 DEBUG org.openhab.core.automation.internal.RuleEngineImpl The rule ‘a77476452e’ is executed.
07:06:14 WARN org.openhab.core.internal.scheduler.SchedulerImpl Scheduled job ‘’ failed and stopped
07:06:15 DEBUG org.openhab.binding.draytonwiser.internal.handler.HeatHubHandler Refreshing devices
07:06:16 DEBUG org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi Sending message to heathub: data/domain/
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/Wiser_Thermostat__Wohn__Esszimmer_Humidity/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomFlurunten_Temperature/state.
07:06:16 DEBUG org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi Sending message to heathub: data/network/Station/
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomFlurunten_SetPoint/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomKackarschland_Temperature/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomKackarschland_SetPoint/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/Wiser_Thermostat__Flur_unten_Set_Point/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomWohnEsszimmer_Temperature/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomWohnEsszimmer_Humidity/state.
07:06:16 DEBUG org.openhab.binding.draytonwiser.internal.handler.HeatHubHandler Finished refreshing devices
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomWohnEsszimmer_SetPoint/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomBadezimmer_Temperature/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomBadezimmer_SetPoint/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserroomKinderzimmer_Temperature/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomKinderzimmer_SetPoint/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomSchlafzimmer_Temperature/state.
07:06:16 DEBUG org.openhab.core.io.monitor.internal.metrics.EventCountMetric Received event on topic openhab/items/WiserRoomSchlafzimmer_SetPoint/state.

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

Hi,

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.

Thanks a lot!!

Now I am trying to activate the two scripts “open Window” and “closed Window” with rules.

The room consists of two windows and a door. All are fitted with Aqara sensors. These are integrated via mqtt and work.

My planned rule in pseudocode:

//Start - open window or door
IF window1 = open or window2 = open or door longer then 5 min = open
Then
Execute script “open Window”
//End

//Start - close window or door
IF (window1 and window2 and door) = close
Then
Execute script “close Window”
//End

Does anyone have any ideas on how I can implement this?

This is not necessary and in fact you should avoid importing Java stuff into JS scripts when using openhab-js.

Replace with

var setPointValue = Quantity("5 °C");

More details in the docs at JavaScript Scripting - Automation | openHAB

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);

More details in the docs at JavaScript Scripting - Automation | openHAB

Threshold Alert and Open Reminder [4.0.0.0;4.9.9.9] can be used to detect if window1 or window2 or door are open longer than 5 minutes. Or you can implement this with a timer. See Design Pattern: Motion Sensor Timer for how to do this with a timer.

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.

Thanks for the great tips.

I am still working on the time delay for the open door.

I am currently trying to create a rule that resets an update of the target temperature when the window is open.

IF Setpoint is chancing and Window is open
THEN RUN script to reduce tempertur to 5°C

I tried it like this but the condition ‘2’ of rule is unsatisfied.
Is this related to the Quanity type?

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.

Yes. You are right. The operation must be !=.

I changed it. But its the same “condition ‘2’ of rule is unsatisfied.”.

Without the code to see which one of those conditions is 2 :man_shrugging:

The IDs count up as you add anything to the rule so which one is 2 depends on when you added the conditions and actions.

autocode

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: WiserRoomWohnEsszimmer_SetPoint
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: EG_KH_WindowSensor_f416_Open__Close
      state: OPEN
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "3"
    configuration:
      itemName: WiserRoomWohnEsszimmer_SetPoint
      state: "'5 °C'"
      operator: "!="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "4"
    configuration:
      considerConditions: true
      ruleUIDs:
        - 85daadbb84
    type: core.RunRuleAction

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.