Пример #1
0
    def prepare(self):
        self.eq3 = maxeq3.eq3data(self.setup.max_ip, 62910)
        self.setup.init_intervals()
        logmsg.start(self.setup.log_filename)
        # update status
        self.status.update('s')
        # initialize bridge values
        bridge.load(self.setup.bridgefile)

        # initialize variables
        self.get_control_values()

        self.queue_msg("S")

        self.get_ip()

        self.eq3.read_data(True)
        # literal processing
        self._literal_process()

        self.export_csv("init")
        self.status.update('i')
Пример #2
0
 def _process_command(self):
     """
     Process command from cmd bridge
     :return: True if quit is received
     """
     cmd = bridge.get_cmd()
     if cmd == "quit":
         return True
     elif cmd[0:6] == "adjust":
         key = cmd[7:]
         if key in self.eq3.ignored_valves:
             del self.eq3.ignored_valves[key]
     elif cmd == "log_debug":
         logmsg.level('D')
     elif cmd == "log_info":
         logmsg.level('I')
     elif cmd[0:4] == "mute":
         self._mute(cmd[5:])
     elif cmd == "rebridge":
         br_data = bridge.load(self.setup.bridge_file)
         self._literal_process(br_data)
         self.update_all()
     elif cmd == "led":
         if self.var.heating:
             self.queue_msg("H")
         else:
             self.queue_msg("S")
     elif cmd == "upgrade":
         self._do_autoupdate()
     # add dummy room, valve, window, for testing, format: add:o = add open window, add:c = add closed window
     # add:r = remove
     elif cmd[0:4] == "dmy:":
         if cmd[4:5] == 'o':
             dummy.add_dummy(True)
         elif cmd[4:5] == 'c':
             dummy.add_dummy(False)
         elif cmd[4:5] == 'r':
             dummy.remove_dummy()
     elif cmd[0:7] == "del_dev:":
         tmp = str(cmd[8:])
         if self.eq3.delete(tmp):
             logmsg.update("Device " + tmp + " deleted successfully.", 'I')
         else:
             logmsg.update("Can't delete device " + tmp, 'I')
Пример #3
0
 def _process_command(self):
     """
     Process command from cmd bridge
     :return: True if quit is received
     """
     cmd = bridge.get_cmd()
     if cmd == "quit":
         return True
     elif cmd[0:6] == "adjust":
         key = cmd[7:]
         if key in self.eq3.ignored_valves:
             del self.eq3.ignored_valves[key]
     elif cmd == "log_debug":
         logmsg.level('D')
     elif cmd == "log_info":
         logmsg.level('I')
     elif cmd[0:4] == "mute":
         self._mute(cmd[5:])
     elif cmd == "rebridge":
         br_data = bridge.load(self.setup.bridge_file)
         self._literal_process(br_data)
         self.update_all()
     elif cmd == "led":
         if self.var.heating:
             self.queue_msg("H")
         else:
             self.queue_msg("S")
     elif cmd == "upgrade":
         self._do_autoupdate()
     # add dummy room, valve, window, for testing, format: add:o = add open window, add:c = add closed window
     # add:r = remove
     elif cmd[0:4] == "dmy:":
         if cmd[4:5] == 'o':
             dummy.add_dummy(True)
         elif cmd[4:5] == 'c':
             dummy.add_dummy(False)
         elif cmd[4:5] == 'r':
             dummy.remove_dummy()
     elif cmd[0:7] == "del_dev:":
         tmp = str(cmd[8:])
         if self.eq3.delete(tmp):
             logmsg.update("Device " + tmp + " deleted successfully.", 'I')
         else:
             logmsg.update("Can't delete device " + tmp, 'I')
Пример #4
0
 def intervals(self):
     # do upgrade according schedule
     if self._is("upg"):
         if not autoupdate.do(self.setup.version, self._is_beta()):
             logmsg.update("Auto update is disabled or failed.")
         else:
             logmsg.update("thermeq3 updated.")
             # sendWarning("upgrade", temp_key, body)
     # do update variables according schedule
     if self._is("var"):
         # >>> updateAllTimes()
         bridge.save(self.setup.bridgefile)
         self.get_ip()
         self.update_ignores_2sit()
     # check max according schedule
     if self._is("max"):
         # beta features here
         if self._is_beta():
             sm, am, kk = profiles.do(self.setup.selectedMode, self.var.actModeIndex, self.var.situation)
             if sm != self.setup.selectedMode or am != self.var.actModeIndex:
                 self.setup.selectedMode = sm
                 self.var.actModeIndex = am
                 self.set_mode(kk)
         # end of beta
         cmd = self._getcmd()
         if cmd == "quit":
             return 0xFF
         elif cmd == "log_debug":
             logmsg.level('D')
         elif cmd == "log_info":
             logmsg.level('I')
         elif cmd[0:4] == "mute":
             key = cmd[4:]
             if key in self.eq3.windows:
                 self.eq3.windows[key][0] = datetime.datetime.now()
                 self.eq3.windows[key][1] = True
                 logmsg.update("OWW for key " + str(key) + " is muted for " + str(
                     self.setup.intervals["oww"][2]) + " seconds.")
         elif cmd == "rebridge":
             bridge.load(self.setup.bridgefile)
             # literal processing
             self._literal_process()
         elif cmd == "updatetime":
             # updateAllTimes()
             pass
         elif cmd == "led":
             if self.var.heating:
                 self.queue_msg("H")
             else:
                 self.queue_msg("S")
         elif cmd == "upgrade":
             # doUpdate()
             pass
         if self.eq3.read_data(False):
             logmsg.update(self._status_msg() + " Every" + str(self.setup.intervals["max"][0]) + " sec", 'I')
             logmsg.update(self.eq3.plain(), 'I')
             # update JSONs
             self.get_control_values()
             self.control()
             # doDevLogging()
             pass
Пример #5
0
    def prepare(self):
        self.eq3 = maxeq3.EQ3Data(self.setup.max_ip, 62910)
        self.setup.init_intervals()
        logmsg.start(self.setup.log_filename)
        logmsg.update("Platform: " + str(support.run_target), 'I')
        self.status.update('s')

        # check if bridge file is in /root, from V230 bridge file is on sd card
        if os.path.exists("/root/" + self.setup.device_name + ".bridge"):
            result = 0
            try:
                result = os.system(
                    "mv /root/" + self.setup.device_name + ".bridge " + self.setup.place + self.setup.device_name +
                    ".bridge")
            except TypeError:
                pass
            if not result >> 8 == 0:
                logmsg.update("Error " + str(result >> 8) + " during moving bridge file.", 'E')

        # load bridge
        br_data = bridge.load(self.setup.bridge_file)
        self._literal_process(br_data)

        # and update with hard coded ignored valves, if needed
        a = self.setup.hard_ignored
        if type(a) is str:
            self.setup.hard_ignored = json.loads(a)

        if self.setup.hard_ignored.viewitems() <= self.eq3.ignored_valves.viewitems():
            logmsg.update("Hard coded ignored valves are already in bridge.", 'I')
        else:
            self.eq3.ignored_valves.update(self.setup.hard_ignored)
            logmsg.update("Ignored valves updated by hard coded ignored valves.", 'I')

        # reinitialize eq3 value for csv
        a = self.setup.csv_values
        ret_value = 1
        if type(a) is str:
            try:
                ret_value = int(a)
            except ValueError:
                logmsg.update("Can't convert csv values read from config file! Using 1 as defaults.", 'E')
            finally:
                self.setup.csv_values = ret_value
        self.eq3.csv_values = self.setup.csv_values
        logmsg.update("Using csv_value=" + str(self.setup.csv_values), 'I')

        # re-initialize variables
        self.get_control_values()

        self.queue_msg("S")
        self.get_ip()

        eq3_result, eq3_error = self.eq3.read_data(True)
        if not eq3_result:
            self.var.heating = None
            self.queue_msg('E')
            # flush error to log
            logmsg.update("".join(str(e) + " " for e in eq3_error), 'E')

        self.export_csv("init")

        self.status.update('i')
        self.update_all()
        secweb.init(self.setup.place)
Пример #6
0
    def prepare(self):
        self.eq3 = maxeq3.EQ3Data(self.setup.max_ip, 62910)
        self.setup.init_intervals()
        logmsg.start(self.setup.log_filename)
        logmsg.update("Platform: " + str(support.run_target), 'I')
        self.status.update('s')

        # check if bridge file is in /root, from V230 bridge file is on sd card
        if os.path.exists("/root/" + self.setup.device_name + ".bridge"):
            result = 0
            try:
                result = os.system("mv /root/" + self.setup.device_name +
                                   ".bridge " + self.setup.place +
                                   self.setup.device_name + ".bridge")
            except TypeError:
                pass
            if not result >> 8 == 0:
                logmsg.update(
                    "Error " + str(result >> 8) +
                    " during moving bridge file.", 'E')

        # load bridge
        br_data = bridge.load(self.setup.bridge_file)
        self._literal_process(br_data)

        # and update with hard coded ignored valves, if needed
        a = self.setup.hard_ignored
        if type(a) is str:
            self.setup.hard_ignored = json.loads(a)

        if self.setup.hard_ignored.viewitems(
        ) <= self.eq3.ignored_valves.viewitems():
            logmsg.update("Hard coded ignored valves are already in bridge.",
                          'I')
        else:
            self.eq3.ignored_valves.update(self.setup.hard_ignored)
            logmsg.update(
                "Ignored valves updated by hard coded ignored valves.", 'I')

        # reinitialize eq3 value for csv
        a = self.setup.csv_values
        ret_value = 1
        if type(a) is str:
            try:
                ret_value = int(a)
            except ValueError:
                logmsg.update(
                    "Can't convert csv values read from config file! Using 1 as defaults.",
                    'E')
            finally:
                self.setup.csv_values = ret_value
        self.eq3.csv_values = self.setup.csv_values
        logmsg.update("Using csv_value=" + str(self.setup.csv_values), 'I')

        # re-initialize variables
        self.get_control_values()

        self.queue_msg("S")
        self.get_ip()

        eq3_result, eq3_error = self.eq3.read_data(True)
        if not eq3_result:
            self.var.heating = None
            self.queue_msg('E')
            # flush error to log
            logmsg.update("".join(str(e) + " " for e in eq3_error), 'E')

        self.export_csv("init")

        self.status.update('i')
        self.update_all()
        secweb.init(self.setup.place)