Implementing Status Request

Posted on
Mon Apr 02, 2018 1:49 pm
Colorado4Wheeler offline
User avatar
Posts: 2715
Joined: Jul 20, 2009
Location: Colorado

Implementing Status Request

What's the method to implement Status Request on non custom devices? I've looked a few times through the documentation and either I don't see it or I'm not getting it, I can turn off the button and that's what I have done until I can figure out how this gets implemented in the plugin.py. I even tore into a couple other plugins seeing if it was obvious and it wasn't.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Apr 02, 2018 2:05 pm
FlyingDiver offline
Posts: 2434
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Implementing Status Request

If you keep the status of the Indigo device up to date with the actual hardware, then this button doesn't do anything.

But if changes are pushed to Indigo from the hardware (and might not get received), and you can somehow interrogate the hardware to get the current status, that's what you do here.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Apr 02, 2018 2:08 pm
FlyingDiver offline
Posts: 2434
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Implementing Status Request

For instance, this is from the MyQ plugin:
Code: Select all
    def actionControlDevice(self, action, dev):

        if action.deviceAction == indigo.kDeviceAction.Unlock:
            self.logger.debug(u"actionControlDevice: \"%s\" Unlock" % dev.name)
            self.changeDevice(dev, kDoorOpen)

        elif action.deviceAction == indigo.kDeviceAction.Lock:
            self.logger.debug(u"actionControlDevice: \"%s\" Lock" % dev.name)
            self.changeDevice(dev, kDoorClose)

        elif action.deviceAction == indigo.kDeviceAction.RequestStatus:
            self.logger.debug(u"actionControlDevice: \"%s\" Request Status" % dev.name)
            self.getDevices()

        else:
            self.logger.error(u"actionControlDevice: \"%s\" Unsupported action requested: %s" % (dev.name, str(action)))



So for a status request, I just call the same routine I do other times that polls the MyQ servers for the current status.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Apr 02, 2018 2:42 pm
Colorado4Wheeler offline
User avatar
Posts: 2715
Joined: Jul 20, 2009
Location: Colorado

Re: Implementing Status Request

FlyingDiver wrote:
        elif action.deviceAction == indigo.kDeviceAction.RequestStatus:
            self.logger.debug(u"actionControlDevice: \"%s\" Request Status" % dev.name)
            self.getDevices()


That's what I was looking for, thank you!

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Apr 02, 2018 2:57 pm
FlyingDiver offline
Posts: 2434
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Implementing Status Request

Another example, from the Lutron plugin:

Code: Select all
        ###### STATUS REQUEST ######
        elif action.deviceAction == indigo.kDeviceAction.RequestStatus:
            if dev.deviceTypeId == RA_PHANTOM_BUTTON:
                phantom_button = dev.pluginProps[PROP_BUTTON]
                integration_id = dev.pluginProps[PROP_REPEATER]
                sendCmd = ("?DEVICE," + str(int(integration_id)) + ","+ str(int(phantom_button)) + ",9,")
            elif dev.deviceTypeId == RA_KEYPAD:
                keypad = dev.pluginProps[PROP_KEYPAD]
                keypadButton = dev.pluginProps[PROP_KEYPADBUT]
                if (int(keypadButton) > 80):
                    sendCmd = ("?DEVICE," + keypad + "," + str(int(keypadButton)) + ",9")
                else:
                    sendCmd = ("?DEVICE," + keypad + "," + str(int(keypadButton)+80) + ",9")
            elif dev.deviceTypeId == RA_DIMMER:
                integration_id = dev.pluginProps[PROP_ZONE]
                sendCmd = ("?OUTPUT," + integration_id + ",1,")
            elif dev.deviceTypeId == RA_SHADE:
                integration_id = dev.pluginProps[PROP_SHADE]
                sendCmd = ("?OUTPUT," + integration_id + ",1,")
            elif dev.deviceTypeId == RA_SWITCH:
                integration_id = dev.pluginProps[PROP_SWITCH]
                sendCmd = ("?OUTPUT," + integration_id + ",1,")
            elif dev.deviceTypeId == RA_CCI:
                self.logger.info(u"This device does not respond to Status Requests")
            elif dev.deviceTypeId == RA_CCO:
                cco = dev.pluginProps[PROP_CCO_INTEGRATION_ID]
                ccoType = dev.pluginProps[PROP_CCO_TYPE]
                if ccoType == "momentary":
                    self.logger.info(u"Momentary CCOs do not respond to Status Requests")
                else:
                    sendCmd = ("?OUTPUT," + cco + ",1,")

        if len(sendCmd):
            self._sendCommand(sendCmd)
            self.logger.debug(u"actionControlDimmerRelay sent: \"%s\" %s %s" % (dev.name, dev.onState, sendCmd))


As it turns out, these are unnecessarily complex due to a decision by the original author to segregate the different device types with different keys in pluginProps. But changing them would require updating all existing devices on the fly, which I haven't tackled yet.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Apr 02, 2018 3:08 pm
Colorado4Wheeler offline
User avatar
Posts: 2715
Joined: Jul 20, 2009
Location: Colorado

Re: Implementing Status Request

I've never implemented the device actions in a plugin before, it wasn't clear to me what the method name was supposed to be.

Code: Select all
def actionControlDevice(self, action, dev):

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: rbdubz3 and 1 guest