IVe created scenes to adress my kaku dimmer from homewizard.
I made this to set dimmer in my homewizard: in LUUP startup
…
function homewizardDim(nummer,status)
local http = require(“socket.http”)
http.TIMEOUT = 5
http.request(“http://192.168.178.29/password/sw/dim/“..nummer..”/“..status..””)
end
…
Using : homewizardDim(11,“90”)
I can set my dimmer (Device 11 in homewizard) to 90%. This works in ‘test luup code’
Now I make 10 scene’s, at 0-10-20-30…-100% of the dimmer slider
But now only 0 (off) works and 90% works.
Cant seem to get the other % to work?
Update : it seems that it only works for the last % I have inserted. I Cant switch to another %. What can I be doing wrong?
It seems likely that you are not formatting the http request correctly. What does a working request entered through a browser look like? Does it work correctly if you just change the dim level in the browser request?
It may be something to do with the trailing empty string in your http request. Try this code which will also log the request in LuaUPnP.log so you can check it:
function homewizardDim(nummer,status)
local http = require("socket.http")
http.TIMEOUT = 5
local httpreq = "http://192.168.178.29/password/sw/dim/"..nummer.."/"..status
luup.log("homewizardDim: " .. httpreq)
http.request({url=httpreq})
end
you are right, there is nothing in the log, I had a report in Mios, that there was an error in LUA files. Ive just deleted all scripts. and only inserted youre code. Error is gone now
This seems to work from “test Luup code”
But i have the same error when triggering (with : homewizardDim(11,“10”)) from a trigger.
How do i setup trigger for dimming :
i make a new Scene (dim 10%)
i select the dimmer and put it on 10%
add trigger, select the dimmer, mode ‘turned on’
add luup : homewizardDim(11,“10”)
-11 is the dimmer
-10 is the % of dimming
save-confirm changes-save
I do this for every 10%, but it keeps only triggering the last % i have added as a scene.
I don’t understand how you are using the virtual dimmer device. I’m also not clear on what your scene is doing. Sorry for the questions but, I can only help once I know what you are doing:
What are you using as a virtual dimmer?
Have you made a single scene with multiple triggers?
What are you using for each trigger?
What is in each trigger’s Luup event?
What is in the scene’s LUUP?
What device action is selected for the scene?
Dont worry, i love questions (got a lot off them myself)
I use : see attachment :
Ok so i add the device (from zip files)
Then i add 10 scenes (for every 10%) eventualy hopfully this will be reduced to 1 dynamic scene
In Apps/Develop apps/Edit startup Lua I add :
function homewizardDim(nummer,status)
local http = require("socket.http")
http.TIMEOUT = 5
local httpreq = "http://192.168.178.29/28feb99/sw/dim/"..nummer.."/"..status
luup.log("homewizardDim: " .. httpreq)
http.request(httpreq)
end
how i build scene :
i make a new Scene (dim 10%)
i select the dimmer and put it on 10% (visually)
add trigger, select the dimmer, mode ‘turned on’
###########
Edit trigger
Device: #27 Dimmer woonkamer
What type of event is the trigger?: A device is turned on or off
Name for this trigger: Dim 10%
Which mode Device is turned on
#############
add luup to trigger : homewizardDim(11,“10”)
-11 is the dimmer device in homewizard
-10 is the % of dimming
save-confirm changes-save
as i add 1 trigger, this works OK
when i add more then 1 trigger, then only the trigger ive made last is activated, for every % i select.
OK - now I understand the problem. You will get the same trigger whenever you change the dim level (as long as it is above zero). This is because the implementation code sets the Status variable to “1” for every non-zero dim level. The trigger that fires could be any but is apparently the last one you defined.
I think you only need two triggers: One for …turns on and one for …turns off. Do not enter any code for Luup event but put this code in the main scene’s LUUP tab (change dID to your V Dimmer number):
local dID = 99 -- Device ID of Virtual Dimmer
local level = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", dID)
homewizardDim(11,level)
Ok, I made 2 scenes, one for on, and one for off. Added Youre code to scene’s luup.
And thesame happens as with the seperate scenes ive made :o
So I can dim to last % I was, switching of works ok.
Ok Some more testing, if I switch off then I can switch on on the % I want! but slider Goes to 10%. Lights go up ok. But to set another value I first have to switch off again…
Yes that is what I would expect. The turned-on trigger can only fire if it was off. If you want to be able to adjust the dim level while the lamp is on, you need to put your homeWizard code in the virtual dimmer implementation code. Then you can just adjust the V Dimmer device and it will send the http directly.
I have attached a file with this added in a very basic way. It does no error checking and uses hard-coded url and homewizard unit number. In practice you would probably want to make them device variables. It should give you a starting point, though.
You will need to upload this file to Vera and change impl_file on the V Dimmer’s Advanced tab and than restart.