Update states and dim/brighten by %

Posted on
Tue Nov 20, 2012 11:34 am
krissh offline
Posts: 105
Joined: Nov 18, 2012
Location: Norway

Update states and dim/brighten by %

Hi!

I'm new to home automation, but have been experimenting with Indigo and RFXCOM for a week or so. I use Nexa wall switches and dimmers/appliances and have a couple of questions I hope some of you can help me with.

As I do not want to rely only on the mac being on and working, some of the wall switches are paired and controlling the dimmers directly. I've been trying to update the state of the devices in a trigger when a wall switch is used (to have correct state in e.g. control page). I've tried applescripts 'set on state of device ... to "On" ' and 'set state of device ... to "On" ' without success. I also tried updateStateOnServer with python, which was not permitted. How can I change the server on state for these devices?

Also, I've tried to use actions dim by % and brighten by % for a dedicated wall switch meant to increase/decrease brightness by 10% at each press. I get the following error in the log, am I doing something wrong? See also image of trigger action.

RFXCOM Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 147, in actionControlDimmerRelay
<type 'exceptions.TypeError'>: TurnBright() takes exactly 4 arguments (3 given)

Best regards
Kristian
Attachments
Skjermbilde 2012-11-20 kl. 18.31.57.png
Skjermbilde 2012-11-20 kl. 18.31.57.png (60.88 KiB) Viewed 2207 times

Posted on
Tue Nov 20, 2012 3:35 pm
RJdeKok offline
Posts: 125
Joined: Mar 27, 2012

Re: Update states and dim/brighten by %

Hi Krissh,

What kind of device is your stue downlights?
Can you make a screendump of its definition?

Posted on
Tue Nov 20, 2012 4:16 pm
krissh offline
Posts: 105
Joined: Nov 18, 2012
Location: Norway

Re: Update states and dim/brighten by %

Hi,

The device is set to AC Dimmer, it is a Nexa CMR-100 dimmer
Attachments
Skjermbilde 2012-11-20 kl. 23.13.28.png
Skjermbilde 2012-11-20 kl. 23.13.28.png (69.63 KiB) Viewed 2177 times

Posted on
Mon Nov 26, 2012 1:43 pm
RJdeKok offline
Posts: 125
Joined: Mar 27, 2012

Re: Update states and dim/brighten by %

I can't reproduce the problem. Are you sure you're using the latest version?
It's available here:http://www.rjdekok.nl/downloads/RFXCOM.indigoPlugin.zip

Posted on
Mon Nov 26, 2012 6:16 pm
krissh offline
Posts: 105
Joined: Nov 18, 2012
Location: Norway

Re: Update states and dim/brighten by %

Thanks! It seems I did in fact have an older version, even though I downloaded from the user contribution library a few days ago. I reinstalled the plugin, and the error messages disappeared, although "dim by %" and "brighten by %" did not seem to work. I took the liberty of playing with your code, the following seems to work, at least for me.

For plugin.py I replaced

Code: Select all
      ###### BRIGHTEN BY ######
      elif action.deviceAction == indigo.kDeviceAction.BrightenBy:
         if self.RFXTRX.TurnBright(action, dev, 0) == True:
            sendSuccess = True      # Set to False if it failed.
         newBrightness = dev.brightness + action.actionValue
         if newBrightness > 100:
            newBrightness = 100
         sendSuccess = True      # Set to False if it failed.
           
         if sendSuccess:
            # If success then log that the command was successfully sent.
            self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "brighten", newBrightness))
               
            # And then tell the Indigo Server to update the state:
            dev.updateStateOnServer("brightnessLevel", newBrightness)
         else:
            # Else log failure but do NOT update state on Indigo Server.
            self.debugLog(u"send \"%s\" %s to %d failed" % (dev.name, "brighten", newBrightness), isError=True)
       
      ###### DIM BY ######
      elif action.deviceAction == indigo.kDeviceAction.DimBy:
         if self.RFXTRX.TurnDim(action, dev) == True:
            sendSuccess = True      # Set to False if it failed.
         newBrightness = dev.brightness - action.actionValue
         if newBrightness < 0:
            newBrightness = 0
         sendSuccess = True      # Set to False if it failed.
           
         if sendSuccess:
            # If success then log that the command was successfully sent.
            self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "dim", newBrightness))
               
            # And then tell the Indigo Server to update the state:
            dev.updateStateOnServer("brightnessLevel", newBrightness)
         else:
            # Else log failure but do NOT update state on Indigo Server.
            indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "dim", newBrightness), isError=True)


with

Code: Select all
      ###### BRIGHTEN BY ######
      elif action.deviceAction == indigo.kDeviceAction.BrightenBy:
         #if self.RFXTRX.TurnBright(action, dev, 0) == True:
         newBrightness = dev.brightness + action.actionValue
         if newBrightness > 100:
            newBrightness = 100
         if self.RFXTRX.TurnBright(action, dev, newBrightness) == True:
            sendSuccess = True      # Set to False if it failed.

         sendSuccess = True      # Set to False if it failed.
           
         if sendSuccess:
            # If success then log that the command was successfully sent.
            self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "brighten", newBrightness))
               
            # And then tell the Indigo Server to update the state:
            dev.updateStateOnServer("brightnessLevel", newBrightness)
         else:
            # Else log failure but do NOT update state on Indigo Server.
            self.debugLog(u"send \"%s\" %s to %d failed" % (dev.name, "brighten", newBrightness), isError=True)
       
      ###### DIM BY ######
      elif action.deviceAction == indigo.kDeviceAction.DimBy:
         #if self.RFXTRX.TurnDim(action, dev) == True:
         newBrightness = dev.brightness - action.actionValue
         if newBrightness < 0:
            newBrightness = 0
         if self.RFXTRX.TurnDim(action, dev, newBrightness) == True:
            sendSuccess = True      # Set to False if it failed.
         sendSuccess = True      # Set to False if it failed.
           
         if sendSuccess:
            # If success then log that the command was successfully sent.
            self.debugLog(u"sent \"%s\" %s to %d" % (dev.name, "dim", newBrightness))
               
            # And then tell the Indigo Server to update the state:
            dev.updateStateOnServer("brightnessLevel", newBrightness)
         else:
            # Else log failure but do NOT update state on Indigo Server.
            indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "dim", newBrightness), isError=True)


and for RFXTRX.py I changed
Code: Select all
   def TurnBright(self, action, dev,BrightLevel):
      return self.TurnDevice(action, dev, 'Bright', BrightLevel)

   def TurnDim(self, action, dev):
      return self.TurnDevice(action, dev, 'Dimm', 0)


to

Code: Select all
   def TurnBright(self, action, dev, BrightLevel):
      return self.TurnDevice(action, dev, 'Bright', BrightLevel)

   def TurnDim(self, action, dev, BrightLevel):
      return self.TurnDevice(action, dev, 'Dimm', BrightLevel)


which seems to work.

BTW, it seems that the code in plugin.py will always set sendSuccess to true, regardless of result?

Posted on
Mon Jan 21, 2013 2:33 pm
RJdeKok offline
Posts: 125
Joined: Mar 27, 2012

Re: Update states and dim/brighten by %

I implement your suggestions in the next release... But with a small correction around the SendSucces.
sendSuccess is the status of the transmit command (always successful). As NEXA devices use one-way communication it is not possible to indicate the status of the NEXA module.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 14 guests