示例#1
0
    def _get_prop(self, prop):

        # print("IN get_prop ", prop)

        if prop == "formatted":
            prop = "ST"
            value = "formatted"
        else:
            value = "value"

        if prop in self._propalias:
            prop = self._propalias[prop]

        if not prop in self._getlist:
            #           if prop in ['parent', 'parent-type']:
            #               return None
            raise IsyE.IsyPropertyError(
                "no property Attribute {!s}".format(prop))

        # check if we have a property

        if prop in ['isLoad', 'location', 'description', 'spoken']:
            if self._nodeprops is None:
                self._nodenotes = self.isy.node_get_notes(
                    self._mydict["address"])
            if self._nodenotes is None:
                return None
            if prop in self._nodenotes:
                return self._nodenotes[prop]
            else:
                # return None
                return ""

        if prop in ['ST', 'OL', 'RR']:
            # Scene's do not have property values

            if "property" in self._mydict and prop in self._mydict["property"]:
                # print(self._mydict["property"])
                # print("prop value", prop, value)
                return self._mydict["property"][prop][value]
            else:
                return None

#            if self._mydict["property"]["time"] == 0:
#                    self.update()
#            elif self.isy.cachetime:
#                if time.gmtime() < (self.cachetime + self._mydict["property"]["time"]):
#                    self.update()

        else:

            #            if prop in self._mydict:
            #               if prop in self._boollist:
            #                   return(val2bool(self._mydict[prop]))
            #               else:
            #                   return self._mydict[prop]
            #            else:
            #                return None

            return super(self.__class__, self)._get_prop(prop)
示例#2
0
    def _set_prop(self, prop, new_value):
        """  generic property set """
        # print("IN set_prop ", prop, new_value)
        if self.debug & 0x04:
            print("_set_prop ", prop, " : ", new_value)

        if prop in self._propalias:
            prop = self._propalias[prop]

        if not prop in self._setlist:
            if prop == "ST":
                self.on(new_value)
                return
            else:
                raise IsyE.IsyPropertyError("_set_prop : " \
                    "Invalid property Attribute " + prop)

        if prop == 'enable':
            self._mydict[prop] = bool(new_value)
            self.isy.node_enable(self._mydict["address"], bool(new_value))

        elif prop in ['OL', 'RR']:
            if not str(new_value).isdigit:
                raise IsyE.IsyTypeError(
                    "Set Property : Bad Value : node=%s prop=%s val=%s" %
                    self._mydict["address"], prop, str(new_value))

            self.isy._node_send(self._mydict["address"], "set", prop,
                                str(new_value))

            # self._mydict["property"]["time"] = 0

            if prop in self._mydict["property"]:
                # if isinstance(new_value, (int, float))  :  # already checked with isdigit
                self._mydict["property"][prop]["value"] = new_value

        # we need to tie this to some action
        elif prop in self._mydict:
            # self._mydict[prop] = new_value
            pass
        else:
            #print("_set_prop AttributeError")
            raise AttributeError("no Attribute " + prop)
示例#3
0
 def __delitem__(self, prop):
     raise IsyE.IsyPropertyError("__delitem__ : can't delete propery :  " +
                                 str(prop))