Ejemplo n.º 1
0
 def update_room_device_option_write_long(self, json_obj, daemon_id):
     """
     Update of the table room_device_option with long KNX value
     """
     query = "SELECT option_id, room_device.room_device_id, addr_plus FROM room_device_option "
     query += "JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id "
     query += "WHERE daemon_id=" + str(daemon_id) + ' AND room_device_option.addr="'
     query += str(json_obj["dst_addr"]) + '"'
     res = self.mysql_handler_personnal_query(query)
     query = "UPDATE room_device_option JOIN room_device ON "
     query += "room_device_option.room_device_id=room_device.room_device_id SET "
     for r in res:
         if int(r[0]) == MasterDaemon.OPTION_VAR:
             up = "UPDATE room_device_option SET valeur="
             if json_obj["value"] == 0:
                 up += "0"
             else:
                 up += "1"
             up += " WHERE room_device_id=" + str(r[1])
             up += " AND option_id=12"
             self.logger.info("update_room_device_option write_long: up = " + up)
             self.mysql_handler_personnal_query(up)
         elif int(r[0]) == MasterDaemon.OPTION_TEMPERATURE or int(r[0]) == MasterDaemon.OPTION_TEMPERATURE_W:
             val = int(json_obj["value"])
             res = utils.convert_temperature(val)
             query += 'valeur="' + str(res) + '" WHERE daemon_id=' + str(daemon_id)
             query += ' AND room_device_option.addr="' + str(json_obj["dst_addr"]) + '"'
             self.logger.info("update_room_device_option write_long: query = " + query)
             self.mysql_handler_personnal_query(query)
         else:
             up = 'UPDATE room_device_option SET valeur="' + str(json_obj["value"])
             up += '" WHERE room_device_id=' + str(r[1]) + ' AND option_id="' + str(r[0]) + '"'
             self.logger.info("update_room_device_option write_long: up = " + up)
             self.mysql_handler_personnal_query(up)
Ejemplo n.º 2
0
 def update_room_device_option_write_long(self, json_obj, daemon_id, db):
     query  = ''.join(["SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id WHERE daemon_id=",
               str(daemon_id), " AND room_device_option.addr=\"", str(json_obj['dst_addr']), "\""]);
     res = self.mysql_handler_personnal_query(query, db);
     if not res:
         query = ''.join(["SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id WHERE ",
                  str(daemon_id), " AND room_device_option.addr_plus=\"", str(json_obj['dst_addr']), "\""]);
         res = self.mysql_handler_personnal_query(query, db);
     for r in res:
         if int(r[0]) == 13:
             if not json_obj['value']:
                 up = 'UPDATE room_device_option SET opt_value=0 WHERE room_device_id=' + str(r[1]) + ' AND option_id=12';
             else:
                 up = 'UPDATE room_device_option SET opt_value=1 WHERE room_device_id=' + str(r[1]) + ' AND option_id=12';
             self.logger.debug('update_room_device_option write_long: up = ' + up);
             self.mysql_handler_personnal_query(up, db);
             query = ''.join(["UPDATE room_device_option SET opt_value=\"", str(json_obj['value']),
                      "\" WHERE room_device_id=", str(r[1]), " AND option_id=", str(r[0])]);
             self.mysql_handler_personnal_query(query, db);
         elif int(r[0]) == 72 or int(r[0]) == 388:
             val = int(json_obj['value']);
             res = utils.convert_temperature(val);
             query = ''.join(["UPDATE room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id SET opt_value=\"",
                      str(res), "\" WHERE daemon_id=", str(daemon_id),
                      " AND room_device_option.addr=\"", str(json_obj['dst_addr']), "\"",
                      " OR ", "room_device_option.addr_plus=\"", str(json_obj['dst_addr']), "\""]);
             self.logger.debug('update_room_device_option write_long: query = ' + query);
             self.mysql_handler_personnal_query(query, db);
         else:
             val = self.functions_transform[r[2]](int(json_obj['value']));
             up = ''.join(["UPDATE room_device_option SET opt_value=\"", str(val),
                  "\" WHERE room_device_id=", str(r[1]), " AND option_id=\"", str(r[0]), "\""]);
             self.logger.debug('update_room_device_option write_long: up = ' + up)
             self.mysql_handler_personnal_query(up, db);
     return res
Ejemplo n.º 3
0
 def update_room_device_option_write_long(self, json_obj, daemon_id, db):
     query = ''.join([
         "SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id WHERE daemon_id=",
         str(daemon_id), " AND room_device_option.addr=\"",
         str(json_obj['dst_addr']), "\""
     ])
     res = self.mysql_handler_personnal_query(query, db)
     if not res:
         query = ''.join([
             "SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id WHERE ",
             str(daemon_id), " AND room_device_option.addr_plus=\"",
             str(json_obj['dst_addr']), "\""
         ])
         res = self.mysql_handler_personnal_query(query, db)
     for r in res:
         if int(r[0]) == 13:
             if not json_obj['value']:
                 up = 'UPDATE room_device_option SET opt_value=0 WHERE room_device_id=' + str(
                     r[1]) + ' AND option_id=12'
             else:
                 up = 'UPDATE room_device_option SET opt_value=1 WHERE room_device_id=' + str(
                     r[1]) + ' AND option_id=12'
             self.logger.debug(
                 'update_room_device_option write_long: up = ' + up)
             self.mysql_handler_personnal_query(up, db)
             query = ''.join([
                 "UPDATE room_device_option SET opt_value=\"",
                 str(json_obj['value']), "\" WHERE room_device_id=",
                 str(r[1]), " AND option_id=",
                 str(r[0])
             ])
             self.mysql_handler_personnal_query(query, db)
         elif int(r[0]) == 72 or int(r[0]) == 388:
             val = int(json_obj['value'])
             res = utils.convert_temperature(val)
             query = ''.join([
                 "UPDATE room_device_option JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id SET opt_value=\"",
                 str(res), "\" WHERE daemon_id=",
                 str(daemon_id), " AND room_device_option.addr=\"",
                 str(json_obj['dst_addr']), "\"", " OR ",
                 "room_device_option.addr_plus=\"",
                 str(json_obj['dst_addr']), "\""
             ])
             self.logger.debug(
                 'update_room_device_option write_long: query = ' + query)
             self.mysql_handler_personnal_query(query, db)
         else:
             val = self.functions_transform[r[2]](int(json_obj['value']))
             up = ''.join([
                 "UPDATE room_device_option SET opt_value=\"",
                 str(val), "\" WHERE room_device_id=",
                 str(r[1]), " AND option_id=\"",
                 str(r[0]), "\""
             ])
             self.logger.debug(
                 'update_room_device_option write_long: up = ' + up)
             self.mysql_handler_personnal_query(up, db)
     return res
Ejemplo n.º 4
0
 def update_room_device_option_resp(self, json_obj, daemon_id):
     """
     Update of the table room_device_option with resp KNX value
     """
     query = "SELECT option_id, room_device.room_device_id FROM ";
     query += "room_device_option JOIN room_device ON ";
     query += "room_device_option.room_device_id=room_device.room_device_id WHERE ";
     query += "daemon_id=" + str(daemon_id) + " AND room_device_option.addr=\"";
     query += str(json_obj['dst_addr']) + "\"";
     
     res = self.mysql_handler_personnal_query(query);
     if type(res).__name__ == 'list':
         for r in res:
             query = "UPDATE room_device_option JOIN room_device ON ";
             query += "room_device_option.room_device_id=room_device.room_device_id SET ";
             if int(r[0]) == OPTION_TEMPERATURE:
                 val = int(json_obj['value']);
                 val = utils.convert_temperature(val);
                 query += "valeur=\"" + str(val) + "\" WHERE daemon_id=" + str(daemon_id);
                 query += " AND room_device_option.addr=\"" + str(json_obj['dst_addr']) + "\"";
                 self.logger.info("update_room_device_option resp query = " + query);
                 self.mysql_handler_personnal_query(query);
             else:
                 query += "valeur=\"" + str(json_obj['value']) + "\" WHERE daemon_id=" + str(daemon_id);
                 query += " AND addr_plus=\"" + str(json_obj['dst_addr']) + "\"";
                 self.logger.info("update_room_device_option resp query = " + query);
                 self.mysql_handler_personnal_query(query);
     else:
         query = "UPDATE room_device_option JOIN room_device ON ";
         query += "room_device_option.room_device_id=room_device.room_device_id SET ";
         if int(r[0]) == OPTION_TEMPERATURE:
             val = int(json_obj['value']);
             val = utils.convert_temperature(val);
             query += "valeur=\"" + str(val) + "\" WHERE daemon_id=" + str(daemon_id);
             query += " AND room_device_option.addr=\"" + str(json_obj['dst_addr']) + "\"";
             self.logger.info("update_room_device_option resp query = " + query);
             self.mysql_handler_personnal_query(query);
         else:
             query += "valeur=\"" + str(json_obj['value']) + "\" WHERE daemon_id=" + str(daemon_id);
             query += " AND addr_plus=\"" + str(json_obj['dst_addr']) + "\"";
             self.logger.info('update_room_device_option resp query = ' + query);
             self.mysql_handler_personnal_query(query);
Ejemplo n.º 5
0
 def update_room_device_option_write_long(self, json_obj, daemon_id):
     """
     Update of the table room_device_option with long KNX value
     """
     query  = "SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM room_device_option ";
     query += "JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id ";
     query += "JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND ";
     query += "dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id ";
     query += "WHERE daemon_id=" + str(daemon_id) + " AND room_device_option.addr=\"";
     query += str(json_obj['dst_addr']) + "\"";
     res = self.mysql_handler_personnal_query(query);
     
     if len(res) == 0:
         query  = "SELECT room_device_option.option_id, room_device.room_device_id, function_answer, dpt_optiondef.dpt_id FROM ";
         query += "room_device_option JOIN room_device ON ";
         query += "room_device_option.room_device_id=room_device.room_device_id ";
         query += "JOIN dpt_optiondef ON dpt_optiondef.option_id=room_device_option.option_id AND ";
         query += "dpt_optiondef.protocol_id=room_device.protocol_id AND dpt_optiondef.dpt_id=room_device_option.dpt_id ";
         query += "WHERE "+ str(daemon_id) + " AND room_device_option.addr_plus=\"";
         query += str(json_obj['dst_addr']) + "\"";
         res = self.mysql_handler_personnal_query(query);
     
     for r in res:
         if int(r[0]) == 13:
             up = 'UPDATE room_device_option SET opt_value=';
             if json_obj['value'] == 0:
                 up += '0';
             else:
                 up += '1';
             up += " WHERE room_device_id=" + str(r[1]);
             up += " AND option_id=12";
             self.logger.debug('update_room_device_option write_long: up = ' + up);
             self.mysql_handler_personnal_query(up);
             
             query = "UPDATE room_device_option SET ";
             query += "opt_value=\"" + str(json_obj['value']) + "\" ";
             query += "WHERE room_device_id=" + str(r[1]) + " AND option_id="+str(r[0]);
             self.mysql_handler_personnal_query(query);
         elif int(r[0]) == 72 or int(r[0]) == 388:
             val = int(json_obj['value']);
             res = utils.convert_temperature(val);
             query = "UPDATE room_device_option JOIN room_device ON ";
             query += "room_device_option.room_device_id=room_device.room_device_id SET ";
             query += "opt_value=\"" + str(res) + "\" WHERE daemon_id=" + str(daemon_id);
             query += " AND room_device_option.addr=\"" + str(json_obj['dst_addr']) + "\"";
             self.logger.debug('update_room_device_option write_long: query = ' + query);
             self.mysql_handler_personnal_query(query);
         else:
             val = self.functions_transform[r[2]](int(json_obj['value']));
             up = "UPDATE room_device_option SET opt_value=\"" + str(val)
             up += "\" WHERE room_device_id=" + str(r[1]) + " AND option_id=\"" + str(r[0]) + "\"";
             self.logger.debug('update_room_device_option write_long: up = ' + up)
             self.mysql_handler_personnal_query(up);
     return res
Ejemplo n.º 6
0
 def update_room_device_option_resp(self, json_obj, daemon_id):
     """
     Update of the table room_device_option with resp KNX value
     """
     query = "SELECT option_id, room_device.room_device_id FROM "
     query += "room_device_option JOIN room_device ON "
     query += "room_device_option.room_device_id=room_device.room_device_id WHERE "
     query += "daemon_id=" + str(daemon_id) + ' AND room_device_option.addr="'
     query += str(json_obj["dst_addr"]) + '"'
     res = self.mysql_handler_personnal_query(query)
     query = "UPDATE room_device_option JOIN room_device ON "
     query += "room_device_option.room_device_id=room_device.room_device_id SET "
     if type(res).__name__ == "list":
         for r in res:
             if int(r[0]) == OPTION_TEMPERATURE:
                 val = int(json_obj["value"])
                 res = utils.convert_temperature(val)
                 query += 'valeur="' + str(res) + '" WHERE daemon_id=' + str(daemon_id)
                 query += ' AND room_device_option.addr="' + str(json_obj["dst_addr"]) + '"'
                 self.logger.info("update_room_device_option resp query = " + query)
                 self.mysql_handler_personnal_query(query)
             else:
                 query += 'valeur="' + str(json_obj["value"]) + '" WHERE daemon_id=' + str(daemon_id)
                 query += ' AND addr_plus="' + str(json_obj["dst_addr"]) + '"'
                 self.logger.info("update_room_device_option resp query = " + query)
                 self.mysql_handler_personnal_query(query)
     else:
         if int(r[0]) == OPTION_TEMPERATURE:
             val = int(json_obj["value"])
             res = utils.convert_temperature(val)
             query += 'valeur="' + str(res) + '" WHERE daemon_id=' + str(daemon_id)
             query += ' AND room_device_option.addr="' + str(json_obj["dst_addr"]) + '"'
             self.logger.info("update_room_device_option resp query = " + query)
             self.mysql_handler_personnal_query(query)
         else:
             query += 'valeur="' + str(json_obj["value"]) + '" WHERE daemon_id=' + str(daemon_id)
             query += ' AND addr_plus="' + str(json_obj["dst_addr"]) + '"'
             self.logger.info("update_room_device_option resp query = " + query)
             self.mysql_handler_personnal_query(query)
Ejemplo n.º 7
0
 def update_room_device_option_write_long(self, json_obj, daemon_id):
     """
     Update of the table room_device_option with long KNX value
     """
     query = "SELECT option_id, room_device.room_device_id, addr_plus FROM room_device_option ";
     query += "JOIN room_device ON room_device_option.room_device_id=room_device.room_device_id ";
     query += "WHERE daemon_id=" + str(daemon_id) + " AND room_device_option.addr=\"";
     query += str(json_obj['dst_addr']) + "\"";
     res = self.mysql_handler_personnal_query(query);
     
     if len(res) == 0:
         query = "SELECT option_id, room_device.room_device_id FROM ";
         query += "room_device_option JOIN room_device ON ";
         query += "room_device_option.room_device_id=room_device.room_device_id WHERE ";
         query += "daemon_id=" + str(daemon_id) + " AND room_device_option.addr_plus=\"";
         query += str(json_obj['dst_addr']) + "\"";
         res = self.mysql_handler_personnal_query(query);
     
     for r in res:
         if int(r[0]) == MasterDaemon.OPTION_VAR:
             up = 'UPDATE room_device_option SET valeur=';
             if json_obj['value'] == 0:
                 up += '0';
             else:
                 up += '1';
             up += " WHERE room_device_id=" + str(r[1]);
             up += " AND option_id=12";
             self.logger.info('update_room_device_option write_long: up = ' + up);
             self.mysql_handler_personnal_query(up);
             
             query = "UPDATE room_device_option SET ";
             query += "valeur=\"" + str(json_obj['value']) + "\" ";
             query += "WHERE room_device_id=" + str(r[1]) + " AND option_id="+str(r[0]);
             self.mysql_handler_personnal_query(query);
         elif int(r[0]) == MasterDaemon.OPTION_TEMPERATURE or int(r[0]) == MasterDaemon.OPTION_TEMPERATURE_W:
             val = int(json_obj['value']);
             res = utils.convert_temperature(val);
             query = "UPDATE room_device_option JOIN room_device ON ";
             query += "room_device_option.room_device_id=room_device.room_device_id SET ";
             query += "valeur=\"" + str(res) + "\" WHERE daemon_id=" + str(daemon_id);
             query += " AND room_device_option.addr=\"" + str(json_obj['dst_addr']) + "\"";
             self.logger.info('update_room_device_option write_long: query = ' + query);
             self.mysql_handler_personnal_query(query);
         else:
             up = "UPDATE room_device_option SET valeur=\"" + str(json_obj['value'])
             up += "\" WHERE room_device_id=" + str(r[1]) + " AND option_id=\"" + str(r[0]) + "\"";
             self.logger.info('update_room_device_option write_long: up = ' + up)
             self.mysql_handler_personnal_query(up);