I gave this a quick read. If I understand this correctly, this library works by parsing the items constantly to monitor any changes, then trigger the rules defined?
Since this is REST based access to OH, any of the channel and thing based triggers won’t work, correct?
Hi @goodfore:
Almost correct - it does not “parse” the items, but listens to the sse events from the rest api. Which means there is no polling, but OpenHAB “notifies” HABApp that an item has changed thus making it way quicker.
On receiving an event it triggers the corresponding rules. It is also possible to listen to different kinds of events and it is even possible to exchange data between rules with the event mechanism of HABApp without openhab knowing about it (this allows passing whole dicts, class instances, etc).
I think the thing events are available, but I have not yet implemented them. What are you listening to currently? The channel events are unfortunately not - you have to bind them to an item.
rule "Mijia & Aqara Wireless Switch"
when
Channel "mihome:sensor_switch:<GwID>:<ID>:button" triggered
then
var actionName = receivedEvent.getEvent()
switch(actionName) {
case "SHORT_PRESSED": {
<ACTION>
}
case "DOUBLE_PRESSED": {
<ACTION>
}
case "LONG_PRESSED": {
<ACTION>
}
case "LONG_RELEASED": {
<ACTION>
}
}
end
I guess that wouldn’t work? I can try binding that to a string item, to see if I can get the events that way.
2019-08-25 02:28:09.927 [.ItemChannelLinkAddedEvent] - Link 'Xm_Button_Event-mihome:sensor_switch:150000000000e4:button' has been added.
2019-08-25 02:28:46.500 [vent.ChannelTriggeredEvent] - mihome:sensor_switch:150000000000e4:button triggered SHORT_PRESSED
2019-08-25 02:32:46.747 [vent.ChannelTriggeredEvent] - mihome:sensor_switch:150000000000e4:button triggered SHORT_PRESSED
2019-08-25 02:32:47.659 [vent.ItemStateChangedEvent] - Dsc_Zone10_General_Status changed from CLOSED to OPEN
2019-08-25 02:32:49.890 [vent.ItemStateChangedEvent] - Xm_Motion3_Status changed from OFF to ON
2019-08-25 02:32:49.899 [vent.ItemStateChangedEvent] - Stair_Motion_Changed changed from 2019-08-25T02:28:49.630-0700 to 2019-08-25T02:32:49.894-0700
2019-08-25 02:32:49.900 [vent.ItemStateChangedEvent] - Motion_Changed changed from 2019-08-25T02:32:39.153-0700 to 2019-08-25T02:32:49.895-0700
2019-08-25 02:32:52.434 [vent.ItemStateChangedEvent] - Dsc_Zone10_General_Status changed from OPEN to CLOSED
Yea - that is the status quo. I am not sure how to subscribe to channel events, Maybe I’ll try removing the topic filter for the rest api in a couple of days and see how it turns out.
Unfortunately the only solution I can propose is to post an update to an item from your rule.
This way it’ll work but it is not a nice solution.
[2019-08-27 00:43:14,069] [ HABApp.Rule] WARNING | Item "mihome:sensor_switch:158d0000000000:button" does not exist (yet)! self.listen_event in "MyButtonRule" may not work as intended.
What are you trying to achieve or what is your problem respectively? is_on() returns true if the switch is on, which in the group case would be if the group state is ON
Group state aggregation is currently not implemented yet. Could you please create an issue with the information from this thread on github?
Meanwhile do