Ap15e
January 12, 2012, 1:06pm
1
What’s wrong with the following UI4 [tt]eventList[/tt]?
"eventList": {
"event_1": {
"label": "Preset button pressed",
"serviceId": "urn:upnp-ap15e-com:serviceId:SPB1",
"norepeat": "0",
"argumentList": {
"argument_1": {
"dataType": "number",
"defaultValue": "",
"allowedValueList": {
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6"
},
"name": "PresetButtonPressed",
"comparisson": "=",
"prefix": "Which preset button?",
"suffix": ""
}
}
}
}
The corresponding UI4 Luup device (see attachment) doesn’t get listed via ‘Scenes’ → ‘Events’ …
Edit:
[tt]http://forum.micasaverde.com/index.php/topic,9059.0.html[/tt]
You can’t have plain numbers for the values in allowedValueList.
This works:
"allowedValueList": {
"a1": "1",
"a2": "2",
"a3": "3",
"a4": "4",
"a5": "5",
"a6": "6"
}
Ap15e
January 13, 2012, 12:53am
3
Thanks.
Is there a way to force [tt]Event::Evaluate[/tt] to kick in even if the value of the variable the event is based on hasn’t changed?
root@HomeControl:/tmp/log/cmh# tail -f LuaUPnP.log | grep SPB
50 01/13/12 1:11:22.197 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_1 171609.616 1 <0x5012>
50 01/13/12 1:11:22.199 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:11:22.200 luup_log:16907: SPB[16907]: button=1 <0x5012>
06 01/13/12 1:11:22.201 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 1 now: 1 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:1 <0x5012>
50 01/13/12 1:13:16.318 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_1 171723.77 1 <0x5012>
50 01/13/12 1:13:16.320 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:13:16.325 luup_log:16907: SPB[16907]: button=1 <0x5012>
06 01/13/12 1:13:16.326 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 1 now: 1 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:1 <0x5012>
50 01/13/12 1:14:54.534 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_2 171821.877 1 <0x5012>
50 01/13/12 1:14:54.540 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:14:54.541 luup_log:16907: SPB[16907]: button=2 <0x5012>
06 01/13/12 1:14:54.542 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 1 now: 2 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:0 <0x5012>
07 01/13/12 1:14:54.695 Event::Evaluate 32 B1 scene TEST SPB is false repeat 0/-1 <0x5012>
50 01/13/12 1:15:00.286 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_1 171824.725 1 <0x5012>
50 01/13/12 1:15:00.293 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:15:00.294 luup_log:16907: SPB[16907]: button=1 <0x5012>
06 01/13/12 1:15:00.295 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 2 now: 1 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:0 <0x5012>
07 01/13/12 1:15:00.445 Event::Evaluate 32 B1 scene TEST SPB is true <0x5012>
08 01/13/12 1:15:00.446 Scene::RunScene running 142 TEST SPB <0x5012>
50 01/13/12 1:15:57.830 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_2 171885.173 1 <0x5012>
50 01/13/12 1:15:57.832 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:15:57.833 luup_log:16907: SPB[16907]: button=2 <0x5012>
06 01/13/12 1:15:57.834 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 1 now: 2 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:0 <0x5012>
07 01/13/12 1:15:57.836 Event::Evaluate 32 B1 scene TEST SPB is false repeat 0/-1 <0x5012>
50 01/13/12 1:16:03.414 luup_log:16907: SPB[16907]: Incoming 00%3A04%3A20%3A1f%3A8b%3Abf button playFavorite_1 171886.625 1 <0x5012>
50 01/13/12 1:16:03.420 luup_log:16907: SPB[16907]: playerid=*00:04:20:1f:8b:bf* LMS_playerid=*00:04:20:1f:8b:bf* <0x5012>
50 01/13/12 1:16:03.421 luup_log:16907: SPB[16907]: button=1 <0x5012>
06 01/13/12 1:16:03.422 Device_Variable::m_szValue_set device: 16907 service: urn:upnp-ap15e-com:serviceId:SPB1 variable: PresetButtonPressed was: 2 now: 1 #hooks: 1 upnp: 0 v:0xcb3280/NONE duplicate:0 <0x5012>
07 01/13/12 1:16:03.575 Event::Evaluate 32 B1 scene TEST SPB is true <0x5012>
08 01/13/12 1:16:03.576 Scene::RunScene running 142 TEST SPB <0x5012>
AFAICT, [tt]norepeat 0/1[/tt] doesn’t seem to make a difference …
In other words:
Press button 1 → event ‘Button 1 pressed’ fires
Press button 1 → event ‘Button 1 pressed’ doesn’t fire
Press button 2 → event ‘Button 1 pressed’ doesn’t fire
Press button 1 → event ‘Button 1 pressed’ fires
Press button 1 → event ‘Button 1 pressed’ doesn’t fire
… and what is needed:
Press button 1 → event ‘Button 1 pressed’ fires
Press button 1 → event ‘Button 1 pressed’ fires
Press button 2 → event ‘Button 1 pressed’ doesn’t fire
Press button 1 → event ‘Button 1 pressed’ fires
Press button 1 → event ‘Button 1 pressed’ fires
BTW, we have been there before:
[tt]http://forum.micasaverde.com/index.php/topic,6004.msg35798.html#msg35798[/tt]
Of course, one could [tt]luup.variable_watch[/tt] the variable the event is based on and reset the variable to 0, but then [tt]Event::Evaluate[/tt] might kick in too late …
Setting the variable to 0 and then to the number of the button (1-6) might work …
Setting the variable to 0 and then to the number of the button (1-6) might work ... That is what I have resorted to.
I think the norepeat was meant only for events like x > y or x < y . Because the way it is designed right now, it would never work for events like A device is turned on or off .
There is a flag that is set when the condition evaluates to true . When this flag is set, the scene won’t run again. The flag is reset when the condition evaluates to false . So, after it runs once, the scene won’t run again as long as the event condition evaluates to true .
Event::Evaluate is triggered by a change in the variable’s value. If I keep pressing the same button, the variable’s value doesn’t change, so Event::Evaluate doesn’t run. If I set the x variable to be 0 , then 1 and then 0 again, the norepeat flag is first set , then it is reset because the condition (which in this example is x == 0) isn’t met when x becomes 1. So when it becomes 0 again, the norepeat flag is in the reset state, so the scene runs again.
Because the way it is designed right now, it would never work for events like A device is turned on or off. That's a pity. There are cases where it makes a lot of sense to repeteadly trigger an event if a watched variable is set to the existing value. Case in point is my tag-reader module. It stores the last tag id received; if you swipe the same tag twice two minutes apart of course you want the trigger to fire twice. There are workarounds, obviously.
Ap15e
January 13, 2012, 6:21pm
7