I equiped all of my doors and windows with Xiaomi door/window sensors a year a go. It works great! As winter arrives quite fast and the heating works heavily, I would like to use the timer functionality of the sensors to alarm, when a window remains open for longer than 5 minutes.
Therefore I set the Item
Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<ID>:isOpenAlarmTimer" }
via system start rule to 5 minutes for every sensor.
When using the alarm in a rule, rule trigger seems to be
Because I have a lot of sensors, I intended to use the group item and functions for grouping these channels and write the notification rule once (makes adding new items easier).
Unfortunately this is not possible… Under my thing, I see all the possible channels. All of them are likable to an Item except isOpenAlarm… linking is denied.
Thanks a lot for your reply… I did it finally with OR as you are suggesting. Unfortunately this has the disadvantage, that I’m not able to identify within the rule, which of the channels has fired to write a specific message like “Window A open for too long” or “Window B open for too long”.
Maybee I have to write a rule for every channel for specific messages…
rule "Fenster Alarm"
when
Channel "mihome:sensor_magnet:xiaomi:DoorSensor1:isOpenAlarm" triggered ALARM or
Channel "mihome:sensor_magnet:xiaomi:DoorSensor2:isOpenAlarm" triggered ALARM
then
//format event
var String chnl = String::format("%s", receivedEvent)
//get ID
val contact = chnl.split(":").get(3)
//find contact switch for ID
val contactSwitch = gContact.members.findFirst[ t | t.name.split("_").get(0) == contact ] as ContactItem
//get room name
val room = contactSwitch.name.split("_").get(2)
logInfo("contact", "Fenster im "+ room +" hat Alarm getriggert!")
end
Unfortunately after moving to OH3 my isOpenAlarm trigger isn’t working anymore! As far as I was able to identify via log Xiaomi Contact Sensor is firing, but within OH3 the trigger is not processed…
See OH3: Xiaomi Sensor Channel isOpenAlarm not working anymore?
No, I haven’t migrated or even tried OH3 yet…
Have you tried to add some more logging to your rule to track down the issue? Especially adding an else statement with a log message to make sure, the if comparison still works as expected?
Jan,
I have OH3 (Build #2142) and this channel is working: 2021-01-16 15:17:12.803 [INFO ] [openhab.event.ChannelTriggeredEvent ] - mihome:sensor_magnet_aq2:f0b429cc84c0:158d0001xxxxx:isOpenAlarm triggered ALARM
I have seen this in the log in many previous versions of OH3.
I
gor
@ip-ua : you are using the Aqara Sensor Magnet (square ones) I’m using the Mi home ones (round). I tied to add the _aq2 extension to mines, but this does not work at all…
@jimSelf : Yes I tried this, the defined rule is not firing.
rule "TFS Reminder Wohnen links"
when
Channel "mihome:sensor_magnet:7811dcxxxx:158d000xxxx:isOpenAlarm" triggered ALARM
then
logInfo("Fensteralarm", "Rule for WohnenLinks fired")
var naOutdoorTemp6 = (Netatmo_Outdoor_Temperature.state as Number)
//logInfo("Test für Rule", "Netatmo ist: " + naOutdoorTemp6 + " der Eckwert ist: " + Cv_TFS_Alarm_Temperature)
if (naOutdoorTemp6.state < Cv_TFS_Alarm_Temperature) {
sendBroadcastNotification("TFS Reminder: Wohnzimmerfenster links schliessen")
logInfo("TFS Reminder", "Wohnzimmerfenster links schliessen")
}
end
But I know, that the isOpenAlarm is firing:
2021-01-17 14:46:06.809 [TRACE] [internal.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"magnet","sid":"158d0001xxxx","short_id":9500,"data":"{\"no_close\":\"60\"}"}
2021-01-17 14:46:06.811 [TRACE] [internal.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0001xxxx
2021-01-17 14:46:06.820 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"magnet","sid":"158d0001xxxx","short_id":9500,"data":"{\"no_close\":\"60\"}"}
It seems that this alarm does not reach the rules…