Hello, I’m a total Vera/Luup newb as of last weekend and I have a question about a custom plugin I’m working on.
I have an older Vantage lighting automation system with a RS-232 port. No web or phone apps, just keypads and scenes. My buddy just bought a Vera 3, and he let me play with it for the week, so I decided to take a shot at writing a plugin to interface with the vantage master controller. Made good progress. I got a usb-to-serial adapter working in Vera with minimal frustration. Then, I wrote custom device and implementation files for the Vantage control unit, and set this parent device up to create child dimmer devices for the lighting loads in my system on startup. I implemented custom SetLoadLevelTarget action that uses run, job, and incoming code to control a light, listen for the response code from the Vantage system, and log the results.
After a little tinkering, everything works great with one exception: the dimmer devices don’t display status correctly in UI5. I would expect this would be a challenge if I changed a light setting from a keypad on the wall (though the Vantage unit does provide a capability to send RS-232 updates when this occurs). However, I can’t seem to figure out why the icons and %s won’t update even when I control the light from UI5. I can’t find the code that controls the UI (other than the dimmer json file), and I can’t find any dimmer actions or variables that result in UI updates.
Ideally, I’d like to have the UI reflect my actions, and I’d like to force UI updates when light levels changed external to Vera. Anyone have thoughts on how to make this work? Thanks.
It would helps us if you posted your code files so we can look at what is going on. What service are you setting for the Dimmer value? Are you setting the value for the correct child device? With out any code to look at, it is very hard to know what is going on and to provide any help.
Yeah, sure, here’s the code, but I think this question may boil down to something more implementation-independent. What I’d really like to find is a simple way to manually control a dimmer device’s UI components in Vera, e.g. show the “on” icon and set the dimmer percentage to 70%. If I could figure that out, then I could both set the UI properly when the dimmer actions were initiated through Vera as well as listen for incoming RS-232 updates when actions were taken from a wall keypad and update the UI accordingly.
You need to send your new dim level to the state-variable that Vera expects. Then the UI will track the change.
luup.variable_set("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", CURRENT_TARGET_VALUE, lul_device)
Ok, thanks. I’ll try that tonight … but I did try basically that same technique last night from the Lua code tester in UI5 and it didn’t seem to have any effect. After setting the variable from there (and then getting and logging it just to be sure it was set correctly), the UI remained unchanged. Anyway, maybe I screwed something up … I’ll try adding the line to my implementation code tonight and see what happens.
As RexBeckett mentioned you need to set the serviceId “urn:upnp-org:serviceId:Dimming1” and variable LoadLevelStatus in order for the UI to reflect the changes. This needs to be done on the child device. The code that RexBeckett provided should get you started. I suggest that you look at some of the other plugins to guide you on what you need to do. They should provide a good starting point.
So your plugin will play nicely with the other kids on the block, you may also want to consider setting the on/off status with:
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1", "Status", newstatus, lul_device)
Where newstatus is “0” or “1”.
For proper compatability, you should also implement the SwitchPower1 action SetTarget and have it issue whatever commands are required before setting Status.
If you do both of these, remote applications should be able to show and control your dimmable-light device.
Got it. Thanks for all your help. I’ll give those changes a try tonight and get back to you with the results.
I made the suggested changes to my code and refactored/improved things in general. Everything now works perfectly, including initial UI dimmer levels and UI updates that originate from wall keypad activities. Thanks to everyone for the advice.
I’ve attached the current implementation code. It’s specific to my house, but, with a few minor modifications to the light load map, it could be easily reused by anyone who has a Vantage Master Controller system. Perhaps one or two people out there might find it useful.