[quote=“oTi@, post:48, topic:169756”]Played with the Minimote (MM) a bit over the weekend to look into options related to controlling dimmers.
By default the MM acts as a scene controller, triggering 4x2 scenes in Vera, losing the ability to change the level of a dimmer from the MM, as previously discussed. There are some workarounds.
[size=12pt]Experimental / Beta[/size]
[size=8pt]Given this uses poorly or un-documented low-level Z-Wave commands and features, and has some delays that may be device dependent, we’ll need to see how well the stuff below works for folks. It was tested with a Leviton and a GE plug-in dimmer.[/size]
[size=11pt]Method A - Make it a regular secondary controller[/size]
Put the following in the Luup sandbox ([tt]Apps[/tt] > [tt]Develop Apps[/tt] > [tt]Test Luup code (Lua)[/tt]):
luup.call_action('urn:micasaverde-com:serviceId:ZWaveNetwork1','SendData',{Node='<nodeID>',Data='x70 4 250 1 0'},1)
Then, while holding the top left button on the MM, click the [tt]Go[/tt] button on the Dashboard.
[size=8pt](The SendData command does not get put on the Wake-Up queue; hence the clunky method to keep the MM awake by holding a button and then sending the command.)
[/size]
This now controls dimmers the same way as when the MM is primary.
Notes:
[size=8pt]Having the MM control the lights directly is nice, but because Vera isn’t in the loop, the status of the dimmer is not updated in Vera until the next poll. So make sure to enable polling for any devices controlled by the MM that support instant status updates (e.g. Leviton), as by default Vera does not poll these devices. Also, for faster updates, you could write a scene on a periodic timer that polls all devices controlled by the MM, and see how it performs.
This method is easy to enable and may suffice if only controlling some lighting devices. If you also want the scene capability in Vera to do more complex things (with some of the buttons), then consider Method B.[/size]
To get back to the scene mode Vera normally configures the MM in (and required for Method B):
luup.call_action('urn:micasaverde-com:serviceId:ZWaveNetwork1','SendData',{Node='<nodeID>',Data='x70 4 250 1 1'},1)
[size=11pt]Method B - Write scenes to control dimming[/size]
Write 2 scenes per button. One for activated and one for de-activated. Besides the appropriate trigger, put the following under the scene’s [tt]Luup[/tt] tab:
[tt]A scene is activated[/tt]:
[code]local DIMMER_DEVID =
local DIMMER_NODEID =
local DIMMER_ON_VALUE =
local MINIMOTE_BUTTON =
local MINIMOTE_DEVID =
local DIMMING_TIMEOUT = 4
local POLL_HOLDOFF = 3
local SC1_SID = ‘urn:micasaverde-com:serviceId:SceneController1’
local ZN1_SID = ‘urn:micasaverde-com:serviceId:ZWaveNetwork1’
local HD1_SID = ‘urn:micasaverde-com:serviceId:HaDevice1’
local D1_SID = ‘urn:upnp-org:serviceId:Dimming1’
local lastSceneTime = luup.variable_get(SC1_SID,‘LastSceneTime’, MINIMOTE_DEVID) or os.time()
local lastSceneDeactivated = luup.variable_get(SC1_SID,‘sl_SceneDeactivated’, MINIMOTE_DEVID) or 0
local loadLevelStatus = luup.variable_get(D1_SID,‘LoadLevelStatus’, DIMMER_DEVID)
lastSceneTime = tonumber(lastSceneTime)
lastSceneDeactivated = tonumber(lastSceneDeactivated)
loadLevelStatus = tonumber(loadLevelStatus)
if ((os.difftime(os.time(),lastSceneTime) < DIMMING_TIMEOUT) and (lastSceneDeactivated == MINIMOTE_BUTTON)) then
luup.call_action(ZN1_SID,‘SendData’,{Node=‘’…DIMMER_NODEID…‘’,Data=‘x26 5’},1)
luup.call_action(HD1_SID,‘Poll’,{},DIMMER_DEVID)
return true
else
if (loadLevelStatus > 0) then
luup.call_action(ZN1_SID,‘SendData’,{Node=‘’…DIMMER_NODEID…‘’,Data=‘x20 1 0’},1)
else
luup.call_action(ZN1_SID,‘SendData’,{Node=‘’…DIMMER_NODEID…‘’,Data=‘x20 1 ‘…DIMMER_ON_VALUE…’’},1)
end
luup.sleep(1000*POLL_HOLDOFF)
luup.call_action(HD1_SID,‘Poll’,{},DIMMER_DEVID)
return true
end[/code]
[size=8pt]Replace the following in the first 5 lines:
with the Device# from the dimmer’s [tt]Settings[/tt] tab.
with the ID from the dimmer’s [tt]Settings[/tt] tab.
with the level the dimmer should be set to (1-100, 255=previous).
with the number of the MM’s button (1-4).
with the Device# from the MM’s [tt]Settings[/tt] tab.[/size]
[tt]A scene is de-activated[/tt]:
[code]local DIMMER_DEVID =
local DIMMER_NODEID =
local DIM_THRESHOLD = 50
local ZN1_SID = ‘urn:micasaverde-com:serviceId:ZWaveNetwork1’
local D1_SID = ‘urn:upnp-org:serviceId:Dimming1’
local loadLevelTarget = luup.variable_get(D1_SID,‘LoadLevelTarget’,DIMMER_DEVID)
loadLevelTarget = tonumber(loadLevelTarget)
if (loadLevelTarget >= DIM_THRESHOLD) then
luup.call_action(ZN1_SID,‘SendData’,{Node=‘’…DIMMER_NODEID…‘’,Data=‘x26 4 x78 99’},1)
luup.variable_set(D1_SID,‘LoadLevelTarget’,‘1’,DIMMER_DEVID)
else
luup.call_action(ZN1_SID,‘SendData’,{Node=‘’…DIMMER_NODEID…‘’,Data=‘x26 4 x38 1’},1)
luup.variable_set(D1_SID,‘LoadLevelTarget’,‘100’,DIMMER_DEVID)
end
return true[/code]
[size=8pt]Replace the following in the first 2 lines:
with the Device# from the dimmer’s [tt]Settings[/tt] tab.
with the ID from the dimmer’s [tt]Settings[/tt] tab.[/size]
A short press of the button should now toggle the dimmer on or off. When turned on, it will be set at the provisioned level (DIMMER_ON_VALUE); you can use 255 to ‘go-to-previous’.
A long press of the button will start ramping up or down. The press only kicks it off, letting go of the button doesn’t stop it; to stop the ramping do a short press.
A poll is done after all state changes, so the status in Vera should update.
Notes:
[size=8pt]Because the short press double as on/off and stop action, you can not go to the off state immediately after changing the level; there is a time-out, currently set at 4 seconds.
Also, the poll after on/off is done with a delay, currently set at 3 seconds, to give the dimmer time to ramp up/down to the final state; otherwise the wrong value will be polled.
So when testing this, keep the slightly altered button behavior and the time-outs/delays in mind.[/size]
[size=11pt]Method C - Program buttons to send any command[/size]
The MM allows the buttons to emit any sequence of bytes to any group of nodes, making it a very customizable device. This could be leveraged, however there appear to be only 2 events per button, so combining on/off and dimming with just 1 button may not be possibe. Given that, plus the complexity to get it set up, as well as the partial implementation of some of the command classes, making it a one-time-only/first-time-right kind of exercise, I decided to consider this method out-of-scope.[/quote]
Just got my minimotes, I setup 2 scenes, one for turning off a light and and one for turning on, assigning them to button 1 and 2.
I’m trying to figure out how to get Method A to work in the above workaround to be able to also control the dim level but I’m not quite sure exactly what steps follow. I did the LUA code with my node ID, and got a confirmation that the message was sent, then my remote no longer send the commands until I did the revert code in the above steps. Was there additional steps to make the dimmer work properly? Ultimately what I’d like to do is button 1 is off with short press and long press lower the light and the same thing for button 2, short press on, long press up the light. Or really any method that provides me the ability to turn on/off and dim the lights.