[ANSWERED] Add Custom Device State Dynamically

Posted on
Tue Feb 09, 2021 5:38 am
autolog offline
Posts: 3519
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Add Custom Device State Dynamically

matt (support) wrote:
... What you want to do is something like this:
Code: Select all
   def getDeviceStateList(self, dev):
      stateList = indigo.PluginBase.getDeviceStateList(self, dev)
      if stateList is not None:
         # Add any dynamic states onto the device based on the node's characteristics.
         if dev-supports-something:
            someNumState = self.getDeviceStateDictForNumberType(u"someNumState", u"Some Level Label", u"Some Level Label")
            someStringState = self.getDeviceStateDictForStringType(u"someStringState", u"Some Level Label", u"Some Level Label")
            someOnOffBoolState = self.getDeviceStateDictForBoolOnOffType(u"someOnOffBoolState", u"Some Level Label", u"Some Level Label")
            someYesNoBoolState = self.getDeviceStateDictForBoolYesNoType(u"someYesNoBoolState", u"Some Level Label", u"Some Level Label")
            someOneZeroBoolState = self.getDeviceStateDictForBoolOneZeroType(u"someOneZeroBoolState", u"Some Level Label", u"Some Level Label")
            someTrueFalseBoolState = self.getDeviceStateDictForBoolTrueFalseType(u"someTrueFalseBoolState", u"Some Level Label", u"Some Level Label")
            stateList.append(someNumState)
            stateList.append(someStringState)
            stateList.append(someOnOffBoolState)
            stateList.append(someYesNoBoolState)
            stateList.append(someOneZeroBoolState)
            stateList.append(someTrueFalseBoolState)
      return stateList



With Indigo 7.5, I am looking fora self.getDeviceStateDictForFloatType but trying that doesn't seem to work?

Can it be added or is there another way to force this? :)

Posted on
Tue Feb 09, 2021 3:54 pm
matt (support) offline
Site Admin
User avatar
Posts: 20610
Joined: Jan 27, 2003
Location: Texas

Re: [ANSWERED] Add Custom Device State Dynamically

Try getDeviceStateDictForRealType(). :twisted:

Image

Who is online

Users browsing this forum: No registered users and 1 guest

cron