def send_to_device(self, json_obj, connection): """ Retrieves the good device in the database and builds the request to send. """ hostname = ''; dm = DeviceManager(int(json_obj['data']['room_device_id']), int(json_obj['data']['option_id']), DEBUG_MODE); dev = dm.load_from_db(); if dev is None: connection.close(); return ; if 'daemon_name' in dev: for host in self.hostlist: if dev['daemon_name'] == host._Hostname: hostname = host._Hostname; break; function_writing = int(dev['function_writing']); if (function_writing > 0): try: self.functions[function_writing](json_obj, dev, hostname); except Exception as e: self.logger.error(e); #add scenario check here to allow trigger on write ??? #self.scenario.check_all_scenarios(self.get_global_state(), self.trigger, self.schedule, connection, json_obj); connection.close();
def send_to_device(self, json_obj, connection): """ Retrieves the good device in the database and builds the request to send. """ dm = DeviceManager(int(json_obj['data']['room_device_id']), int(json_obj['data']['option_id']), DEBUG_MODE); dev = dm.load_from_db(); if dev is None: connection.close(); return ; hostname = ''; for host in self.hostlist: if dev['daemon_name'] in host._Hostname: hostname = host._Hostname; break; if hostname != '': if dev['protocol_id'] == PROTOCOL_KNX: self.knx_manager.protocol_knx(json_obj, dev, hostname); elif dev['protocol_id'] == PROTOCOL_IP: json_obj['addr'] = dev['addr']; json_obj['port'] = dev['plus1']; self.protocol_function[dev['protocol_id']](json_obj, dev, hostname); connection.close();
def send_to_device(self, json_obj, connection, db): """ Retrieves the good device in the database and builds the request to send. """ hostname = ''; dm = DeviceManager(int(json_obj['data']['room_device_id']), int(json_obj['data']['option_id']), DEBUG_MODE); dev = dm.load_from_db(db); if dev is None: connection.close(); return ; if 'daemon_name' in dev: for host in self.hostlist: if dev['daemon_name'] == host._Hostname: hostname = host._Hostname; break; function_writing = int(dev['function_writing']); if (function_writing > 0): try: self.functions[function_writing](json_obj, dev, hostname); except Exception as e: self.logger.error(e); connection.close();