Exemplo n.º 1
0
def do(sel_mode, act_idx, sit):
    """
    Performs day or temp mode selection
    :param sel_mode: char, selected mode
    :param act_idx:  integer, actual index
    :param sit: dictionary, weather situation
    :return: list
    """
    # update variables from main code
    global table
    table.selected_mode = sel_mode
    table.act_mode_idx = act_idx
    table.sit = sit
    tmp_prof = bridge.try_read("profile", True).upper()
    kv = []
    if tmp_prof != table.selected_mode:
        table.selected_mode = tmp_prof
        table.act_mode_idx = -1
    if tmp_prof == "TIME":
        check_day_table()
        kv = time_mode()
    elif tmp_prof == "TEMP":
        kv = temp_mode()

    return [table.selected_mode, table.act_mode_idx, kv]
Exemplo n.º 2
0
    def control(self):
        self.check_var()
        open_windows = self.get_open_windows()

        # process open windows
        self.process_windows(open_windows)

        # and now showtime
        # heat: 0 = disable, 1 = heat per, 2 = total, 3 = svpnmw
        # heat, grt, heat_valve = self.heat_or_not_room()
        heat, grt, heat_valve = self.heat_or_not()

        # increment number of readings with heat on
        if bool(heat):
            self.var.heat_readings += 1

        if bool(heat) != self.var.heating:
            mode = bridge.try_read("mode").upper() == "AUTO"
            logmsg.debug("mode=", mode,
                         ", heat=", heat,
                         ", bool(heat)=", bool(heat))
            if heat > 0:
                logmsg.update(self.get_heat_string(heat, heat_valve, grt), 'I')
            else:
                logmsg.update("heating stopped.", 'I')
            if mode:
                self._do_heat(bool(heat))
Exemplo n.º 3
0
def do(sel_mode, act_idx, sit):
    """
    Performs day or temp mode selection
    :param sel_mode: char, selected mode
    :param act_idx:  integer, actual index
    :param sit: dictionary, weather situation
    :return: list
    """
    # update variables from main code
    global table
    table.selected_mode = sel_mode
    table.act_mode_idx = act_idx
    table.sit = sit
    tmp_prof = bridge.try_read("profile", True).upper()
    kv = []
    if tmp_prof != table.selected_mode:
        table.selected_mode = tmp_prof
        table.act_mode_idx = -1
    if tmp_prof == "TIME":
        check_day_table()
        kv = time_mode()
    elif tmp_prof == "TEMP":
        kv = temp_mode()

    return [table.selected_mode, table.act_mode_idx, kv]
Exemplo n.º 4
0
    def write_strings(self):
        """ construct and write CSV data, Log debug string and current status string """
        log_str = bridge.try_read("status", False) + ", "
        if self.setup.preference == "per":
            log_str += str(self.setup.valve_switch) + "%" + " at " + str(
                self.setup.valve_num) + " valve(s)."
        elif self.setup.preference == "total":
            log_str += "total value of " + str(self.setup.total_switch) + "."
        log_str += "\n"

        csvfile.write(time.strftime("%d/%m/%Y %H:%M:%S", time.localtime()),
                      1 if self.var.heating else 0,
                      1 if self.var.ventilating else 0)
        csvfile.write(self.eq3.csv())
        csvfile.write("\n")

        # second web
        # JSON formatted status
        json_status = self.eq3.json_status()
        secweb.write("status", json_status)
        # and bridge variable
        bridge.put("sys", json_status)
        # nice text web
        secweb.nice(log_str + self.eq3.plain())
        # readiness for dashboard
        bridge.save(secweb.sw.location["bridge"])
Exemplo n.º 5
0
    def control(self):
        self.check_var()
        open_windows = self.get_open_windows()

        # process open windows
        self.process_windows(open_windows)

        # and now showtime
        # heat: 0 = disable, 1 = heat per, 2 = total, 3 = svpnmw
        # heat, grt, heat_valve = self.heat_or_not_room()
        heat, grt, heat_valve = self.heat_or_not()

        # increment number of readings with heat on
        if bool(heat):
            self.var.heat_readings += 1

        if bool(heat) != self.var.heating:
            mode = bridge.try_read("mode").upper() == "AUTO"
            logmsg.debug("mode=", mode, ", heat=", heat, ", bool(heat)=",
                         bool(heat))
            if heat > 0:
                logmsg.update(self.get_heat_string(heat, heat_valve, grt), 'I')
            else:
                logmsg.update("heating stopped.", 'I')
            if mode:
                self._do_heat(bool(heat))
Exemplo n.º 6
0
 def get_control_values(self):
     """ read control values from bridge """
     # try read preference settings, total or per
     self.setup.preference = bridge.try_read("pref")
     # try read % valve for heat command
     self.setup.valve_switch = bridge.try_read("valve")
     self.setup.svpnmw = bridge.try_read("svpnmw")
     self.setup.total_switch = bridge.try_read("total")
     # try get readMAX interval value, if not set it
     self.setup.intervals["max"][0] = bridge.try_read("int")
     self.setup.intervals["slp"][0] = self.setup.intervals["max"][0] / self.setup.intervals["slp"][1]
     # try read num of valves to turn heat on
     self.setup.valve_num = bridge.try_read("valves")
     # try read if auto update is OK
     self.setup.au = bridge.try_read("au")
     # try read how many minutes you can ignore valve after closing window
     self.eq3.ignore_time = bridge.try_read("ign_op")
     # and if open windows warning is disabled, 0 = enables, 1 = disabled
     self.setup.no_oww = bridge.try_read("no_oww")
     self.setup.selected_mode = bridge.try_read("profile")
Exemplo n.º 7
0
 def get_control_values(self):
     """ read control values from bridge """
     # try read preference settings, total or per
     self.setup.preference = bridge.try_read("pref")
     # try read % valve for heat command
     self.setup.valve_switch = bridge.try_read("valve")
     self.setup.svpnmw = bridge.try_read("svpnmw")
     self.setup.total_switch = bridge.try_read("total")
     # try get readMAX interval value, if not set it
     self.setup.intervals["max"][0] = bridge.try_read("int")
     self.setup.intervals["slp"][0] = self.setup.intervals["max"][
         0] / self.setup.intervals["slp"][1]
     # try read num of valves to turn heat on
     self.setup.valve_num = bridge.try_read("valves")
     # try read if auto update is OK
     self.setup.au = bridge.try_read("au")
     # try read how many minutes you can ignore valve after closing window
     self.eq3.ignore_time = bridge.try_read("ign_op")
     # and if open windows warning is disabled, 0 = enables, 1 = disabled
     self.setup.no_oww = bridge.try_read("no_oww")
     self.setup.selected_mode = bridge.try_read("profile")
Exemplo n.º 8
0
    def write_strings(self):
        """ construct and write CSV data, Log debug string and current status string """
        log_str = bridge.try_read("status", False) + ", "
        if self.setup.preference == "per":
            log_str += str(self.setup.valve_switch) + "%" + " at " + str(self.setup.valve_num) + " valve(s)."
        elif self.setup.preference == "total":
            log_str += "total value of " + str(self.setup.total_switch) + "."
        log_str += "\n"

        csvfile.write(time.strftime("%d/%m/%Y %H:%M:%S", time.localtime()),
                      1 if self.var.heating else 0, 1 if self.var.ventilating else 0)
        csvfile.write(self.eq3.csv())
        csvfile.write("\n")

        # second web
        # JSON formatted status
        json_status = self.eq3.json_status()
        secweb.write("status", json_status)
        # and bridge variable
        bridge.put("sys", json_status)
        # nice text web
        secweb.nice(log_str + self.eq3.plain())
        # readiness for dashboard
        bridge.save(secweb.sw.location["bridge"])
Exemplo n.º 9
0
    def control(self):
        tmp = {}
        open_windows = []
        for k, v in self.eq3.devices.iteritems():
            if v[4] == 2:
                room_id = str(v[3])
                room_name = str(self.eq3.rooms[room_id][0])
                tmp.update({k: room_name})

            if self._isWinOpenTooLong(k):
                open_windows.append(k)
                logmsg.update("Warning condition for window " + str(k) + " met")
            if self.eq3.isBattError(k):
                # send_warning("battery", k, "")
                pass
            if self.eq3.isRadioError(k):
                # send_warning("error", k, "")
                pass

        # check if ventilate and if not then send warning
        if not self.setup.no_oww and len(open_windows) < self.setup.ventilate_num:
            for idx, k in enumerate(open_windows):
                # send_warning("window", k, "")
                pass
        # else check if ventilating and update status
        else:
            if len(open_windows) >= self.setup.ventilate_num:
                self.var.ventilating = True
            else:
                self.var.ventilating = False

        # second web
        # secWebFile("owl", tmp)

        if self.var.err2Clear and not self.var.error:
            self.queue_msg("C")
        if self.var.err2LastStatus:
            self.var.err2LastStatus = False
            if self.var.heating:
                self.queue_msg("H")
                logmsg.update("Resuming heating state on status LED")

        # and now showtime
        # heat: 0 = disable, 1 = heat per, 2 = total, 3 = svpnmw
        heat = 0
        grt = 0
        valve_count = 0
        heat_valve = {}

        for k, v in self.eq3.valves.iteritems():
            # if valve is ok to evaluate
            if self.eq3.countValve(k):
                # if preference is per valve
                if self.setup.preference == "per":
                    # and valve position is over single valve position no matter what
                    if v[0] > self.setup.svpnmw:
                        heat = 3
                    # or valve is over desired position to switch heating on
                    elif v[0] > self.setup.valve_switch:
                        valve_count += 1
                        if valve_count >= self.setup.valve_num:
                            heat = 1
                            heat_valve.update(self.eq3.getKeyName(k))
                elif self.setup.preference == "total":
                    grt += v[0]
                    if grt >= self.setup.total_switch:
                        heat = 2

        # increment number of readings with heat on
        if heat:
            self.var.heatReadings += 1

        if bool(heat) != self.var.heating:
            if heat > 0:
                txt = "heating started due to"
                if heat == 1 and valve_count >= self.setup.valve_num:
                    for k, v in heat_valve.iteritems():
                        txt += " room " + str(v[0]) + ", valve " + str(v[1]) + "@" + str(v[2])
                elif heat == 2:
                    txt += " sum of valve positions = " + str(grt)
                elif heat == 3:
                    txt += " single valve position, no matter what " + str(self.setup.svpnmw) + "%"
                logmsg.update(txt)
                if bridge.try_read("mode", "auto", True).upper() == "AUTO":
                    self._do_heat(True)
            else:
                logmsg.update("heating stopped.")
                if bridge.try_read("mode", "auto", True).upper() == "AUTO":
                    self._do_heat(False)
Exemplo n.º 10
0
 def _is_beta(self):
     return (bridge.try_read("beta", "no", False).upper() == "YES")
Exemplo n.º 11
0
 def _is_beta():
     return bridge.try_read("beta", False).upper() == "YES"
Exemplo n.º 12
0
 def _is_beta():
     return bridge.try_read("beta", False).upper() == "YES"