示例#1
0
    def _on(self, val, cmd):
        if not str(val).isdigit:
            raise IsyE.IsyTypeError(
                "On Command : Bad Value : node=%s val=%s" %
                self._mydict["address"], str(val))

        if "property" in self._mydict:
            if "ST" in self._mydict["property"]:
                self._mydict["property"]["ST"]["value"] = str(val)
                if self._dimable:
                    self._mydict["property"]["ST"][
                        "formatted"] = "{:.0%}".format(val / 255)
                else:
                    self._mydict["property"]["ST"]["formatted"] = "On"

        self.isy._node_send(self._mydict["address"], "cmd", cmd, val)
示例#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)