def put(self, n, _ts, key, values): if key[0] is None or command.IsCustom(key): return name = command.StringifyCommand(key) # print("@@@IN", name, values) self._mqtt_client.publish( "zwave_in/%d/%d/%s" % (self._home_id, n, name), json.dumps(values, cls=PythonObjectEncoder))
def put(self, ts, key, values): self.last_contact = ts if key == command.CUSTOM_COMMAND_APPLICATION_UPDATE: self._InitializeCommands(values["type"], values["commands"], values["controls"]) self.MaybeChangeState(NODE_STATE_DISCOVERED) if self.state >= NODE_STATE_INTERVIEWED: self.RefreshDynamicValues() self.RefreshSemiStaticValues() return if self.state < NODE_STATE_DISCOVERED and not command.IsCustom(key): self._translator.Ping(self.n, 3, False, "undiscovered") if key == z.MultiChannel_CapabilityReport: logging.warning("FOUND MULTICHANNEL ENDPOINT: %s", values) special = _COMMANDS_WITH_SPECIAL_ACTIONS.get(key) if special: special(ts, self, values) key_ex = _COMMANDS_WITH_MAP_VALUES.get(key) if key_ex: self.values.SetMapEntry(ts, key, key_ex(values), values) else: self.values.Set(ts, key, values) # elif a == command.ACTION_STORE_SCENE: # if value[0] == 0: # # TODO # #self._values[command.VALUE_ACTIVE_SCENE] = -1 # pass # else: # self.scenes[value[0]] = value[1:] # elif a == command.SECURITY_SCHEME: # assert len(value) == 1 # if value[0] == 0: # # not paired yet start key exchange # self.SecurityChangeKey(self._shared,security_key) # else: # # already paired # self.SecurityRequestClasses() return
def put(self, ts: float, key: tuple, values: Dict): """A Node receives new commands via this function""" self.last_contact = ts if key == command.CUSTOM_COMMAND_APPLICATION_UPDATE: # maybe update generic+specific device if self.values.Get(command.CUSTOM_COMMAND_PROTOCOL_INFO) is None: self.values.Set( ts, command.CUSTOM_COMMAND_PROTOCOL_INFO, { "device_type": ( 0, values["generic"], values["specific"])}) k = values["generic"] * 256 + values["specific"] v = z.GENERIC_SPECIFIC_DB.get(k) if v is None: logging.error("[%d] unknown generic device : %s", self.n, repr(values)) return self.InitializeUnversioned( values["commands"], values["controls"], v[1], v[2]) self.MaybeChangeState(NODE_STATE_DISCOVERED) if self.state >= NODE_STATE_INTERVIEWED: self.RefreshDynamicValues() self.RefreshSemiStaticValues() return if self.state < NODE_STATE_DISCOVERED and not command.IsCustom(key): self._translator.Ping(self.n, 3, False, "undiscovered") items_extractor = _COMMANDS_WITH_MAP_VALUES.get(key) if items_extractor: for k, v in items_extractor(values): self.values.SetMapEntry(ts, key, k, v) else: self.values.Set(ts, key, values) special = _COMMANDS_WITH_SPECIAL_ACTIONS.get(key) if special: special(ts, self, values)