can you set the dim level of a leviton dimmer without turning it on?

I am looking for a way to preset the light level on some of my leviton dimmers based on the time of day. For example, in the bedroom between midnight and 6am, I’d like to set the level to something like 10% so that if I tap the light it doesn’t blind me. But if it’s 9pm, I want the light to come on at say 75%. I know I can fire scenes based on time, but is there a way to preset the light level?

Yes, the in commands tab of your scenes, rather than selecting On or Off as the command, just select “SetLevel” instead, and then enter the desired numeric level in the text entry box that will appear after selecting it in the dropdown.

I tried doing that, but setting the level turns the light on at the level you set in the box when the scene fires. I’m looking for a way to predetermine the default level of the light based on the time of day.
Thanks,
Bill

1 Like

According to the UPnP specification (“Dimming:1 Service Template Version 1.01”) you must:

Set the state variable [tt]OnEffect[/tt] to the string [tt]OnEffectLevel[/tt],
set the state variable [tt]OnEffectLevel[/tt] to the desired dim level.

The corresponding UPnP actions are [tt]SetOnEffect[/tt] (argument: [tt]NewOnEffect[/tt]) and [tt]SetOnEffectLevel[/tt] (argument: [tt]NewOnEffectLevel[/tt]).

See http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_call_action for information about calling UPnP actions from Luup.

According to the UPnP specification the implementation of [tt]SetOnEffect[/tt] and [tt]SetOnEffectLevel[/tt] is optional (Vera’s [tt]S_Dimming1.xml[/tt] does contain the required actions, but http://wiki.micasaverde.com/index.php/Luup_UPNP_Files lists only [tt]SetLoadLevelTarget[/tt]) …

Please report back your results.

Here are my results (V1@1.1.1186):

devid = 4

res, resstr, job, retargs = luup.call_action( "urn:upnp-org:serviceId:Dimming1", 
                                              "SetOnEffect"                    , 
                                              { NewOnEffect ='OnEffectLevel' } , 
                                              devid                              )

luup.log( 'DDDDD SetOnEffect      res='..tostring(res)..' resstr='..tostring(resstr)..' job='..tostring(job)..' retargs='..tostring(retargs) )

res, resstr, job, retargs = luup.call_action( "urn:upnp-org:serviceId:Dimming1", 
                                              "SetOnEffectLevel"               , 
                                              { NewOnEffectLevel = '10' }      , 
                                              devid                              )

luup.log('DDDDD SetOnEffectLevel res='..tostring(res)..' resstr='..tostring(resstr)..' job='..tostring(job)..' retargs='..tostring(retargs) )

50      04/07/11 13:46:39.019   luup_log:0: DDDDD SetOnEffect      res=-115 resstr=Device does not handle service/action job=0 retargs=table: 0xad90b0 <0x300d>
50      04/07/11 13:46:39.024   luup_log:0: DDDDD SetOnEffectLevel res=-115 resstr=Device does not handle service/action job=0 retargs=table: 0x945628 <0x300d>

Thanks for the code! I will try this tonight and report back with my results.

I tried putting the code in the luup tab of a scene, but it doesn’t seem to work. I’ve never used the logging feature before so I’m not sure how to troubleshoot. I can’t find the luup.log file. Any pointers?
Thanks,
Bill

Please adjust the device id in line 1.

http://wiki.micasaverde.com/index.php/Luup_Debugging

I’ve got a v1@1.1.1183

When I execute this, where the devid corresponds to a Leviton VIR06 dimmer:

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus",  devid )
  logger( devid..' get LoadLevelStatus: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "OnEffectLevel",  devid )
  logger( devid..' get OnEffectLevel: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "OnEffect",  devid )
  logger( devid..' get OnEffect: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget",  devid )
  logger( devid..' get LoadLevelTarget: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "RampRate",  devid )
  logger( devid..' get RampRate: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "RampTime",  devid )
  logger( devid..' get RampTime: '..tostring(val)..' @ '..tostring(time) )

  luup.variable_set("urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget",  '45', devid )
  logger( devid..' set LoadLevelTarget')

I get this in my log:

2011-04-09 19:57:49 : 18 get LoadLevelStatus: 0 @ 1302402958 2011-04-09 19:57:49 : 18 get OnEffectLevel: nil @ nil 2011-04-09 19:57:49 : 18 get OnEffect: nil @ nil 2011-04-09 19:57:49 : 18 get LoadLevelTarget: 45 @ 1302403122 2011-04-09 19:57:49 : 18 get RampRate: nil @ nil 2011-04-09 19:57:49 : 18 get RampTime: nil @ nil 2011-04-09 19:57:49 : 18 set LoadLevelTarget

So I can’t seem to get (or set) OnEffect / OnEffectLevel / RampLevel / RampTime
But I can get / set LoadLevelTarget
What does LoadLevelTarget do? I can set/get it, but it doesn’t seem to do anything.

My Leviton remote reports that this dimmer is:

Slave Enhanced
ZW Version: 2.09
App Version: 0.04

–Jim

Please download [tt]http://upnp.org/resources/upnpresources.zip[/tt] and please read [tt]UPnP-ha-Dimming-v1-Service-20031123.pdf[/tt].

There are UPnP variables and there are UPnP actions. [tt]luup.variable_get()[/tt] doesn’t work for actions, and [tt]luup.call_action()[/tt] doesn’t work for variables.

Thanks for the pointer to the UPnP background.
Some interesting observations from my Vera and its file “S_Dimming1.xml”:

This works:

  local res, resstr, job, retargs = luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="45" }, devid)

This does not work:

  local res, resstr, job, retargs = luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ NewLoadlevelTarget="45" }, devid)

But in any case the results are the same as far as “OnEffect” goes:

  local res, resstr, job, retargs = luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetOnEffect",{ newOnEffect="OnEffectLevel" }, devid )
  logger('SetOnEffect        res='..tostring(res)..' resstr='..tostring(resstr)..' job='..tostring(job)..' retargs='..tostring(retargs) )

  local res, resstr, job, retargs = luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetOnEffectLevel",{ newOnEffectLevel="75"}, devid )
  logger('SetOnEffectLevel   res='..tostring(res)..' resstr='..tostring(resstr)..' job='..tostring(job)..' retargs='..tostring(retargs) )

  local res, resstr, job, retargs = luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="45" }, devid)
  logger('SetLoadLevelTarget res='..tostring(res)..' resstr='..tostring(resstr)..' job='..tostring(job)..' retargs='..tostring(retargs) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus",  devid )
  logger( devid..' get LoadLevelStatus: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "OnEffectLevel",  devid )
  logger( devid..' get OnEffectLevel: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "OnEffect",  devid )
  logger( devid..' get OnEffect: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget",  devid )
  logger( devid..' get LoadLevelTarget: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "RampRate",  devid )
  logger( devid..' get RampRate: '..tostring(val)..' @ '..tostring(time) )

  local val, time = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "RampTime",  devid )
  logger( devid..' get RampTime: '..tostring(val)..' @ '..tostring(time) )

Produces:

2011-04-10 14:15:58 :   SetOnEffect        res=-115 resstr=Device does not handle service/action job=0 retargs=table: 0x906208
2011-04-10 14:15:58 :   SetOnEffectLevel   res=-115 resstr=Device does not handle service/action job=0 retargs=table: 0x7f32d0
2011-04-10 14:15:58 :   SetLoadLevelTarget res=0 resstr= job=2498 retargs=table: 0x808528
2011-04-10 14:15:58 :   18 get LoadLevelStatus: 0 @ 1302470137
2011-04-10 14:15:58 :   18 get OnEffectLevel: nil @ nil
2011-04-10 14:15:58 :   18 get OnEffect: nil @ nil
2011-04-10 14:15:58 :   18 get LoadLevelTarget: 45 @ 1302470158
2011-04-10 14:15:58 :   18 get RampRate: nil @ nil
2011-04-10 14:15:58 :   18 get RampTime: nil @ nil