I am attempting to use a standard dimmer control to control volume (via slider) and power (via on / off buttons) on an AV receiver. I would like this to remain on a standard dimmer device so that it can be controlled from third party apps (such as Imperihome).
I have the code worked out for communication with the receiver and I have the volume control working on the virtual dimmer, however i cannot seem to get the on / off to trigger SwitchPower. Instead On / Off sets the slider level to 0 / 100 respectively.
I created a custom implementation file containing the following (sloppy) code, which never executes:
[code]
urn:upnp-org:serviceId:SwitchPower1
SetTarget
local deviceID
–336 = living room amp
–337 = loft amp
–105 = living room amp volume control
–107 = loft volume control
if lul_device == 105 then
--Living Room Volume Control
deviceID = 336
elseif lul_device == 107 then
--Loft Volume Control
deviceID = 337
end
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", lul_settings.newTargetValue, deviceID)
</run>
[/code]
It looks like the json file is setting the loadlevel status instead of the dimmer instead of the status of SwitchPower, so I also tried creating a custom json file for this dimmer, modifying some of the control tags as below (copying the binary switch file).
"Control": [
{
"ControlGroup": "1",
"ControlType": "multi_state_button",
"top": "0",
"left": "1",
"states":[
{
"Label": {
"lang_tag": "ui7_cmd_on",
"text": "On"
},
"ControlGroup": "1",
"Display": {
"Service": "urn:upnp-org:serviceId:SwitchPower1", --Changed from urn:upnp-org:serviceId:Dimming1
"Variable": "Status", -- Changed from LoadLevelStatus
"Value": "1" -- Changed from 100, typically changed for the remainder of this code snippet
},
"Command": {
"Service": "urn:upnp-org:serviceId:SwitchPower1",
"Action": "SetTarget",
"Parameters": [
{
"Name": "newTargetValue",
"Value": "1"
}
]
},
"ControlCode": "power_on"
},
{
"Label": {
"lang_tag": "ui7_cmd_off",
"text": "Off"
},
"ControlGroup": "1",
"Display": {
"Service": "urn:upnp-org:serviceId:SwitchPower1",
"Variable": "Status",
"Value": "0"
},
"Command": {
"Service": "urn:upnp-org:serviceId:SwitchPower1",
"Action": "SetTarget",
"Parameters": [
{
"Name": "newTargetValue",
"Value": "0"
}
]
},
"ControlCode": "power_off"
}
]
Am I approaching this incorrectly? It seems like it should be trivial, but it’s eating my lunch.