def execute(self, module, input):
        if self.fallbackTimer != None:
            self.fallbackTimer.cancel()
            self.fallbackTimer = None

        presenceState = getItemState("pOther_Presence_State").intValue()

        if input['event'].getItemName(
        ) == "pGF_Corridor_Openingcontact_Door_State":
            if self.confirmTimer != None:
                self.confirmTimer.cancel()
                self.confirmTimer = None

            self.isConfirmed = False

            if input['event'].getItemState() == OPEN:
                if presenceState == PresenceHelper.STATE_AWAY:
                    postUpdate("pOther_Presence_State",
                               PresenceHelper.STATE_MAYBE_PRESENT)
                    sendNotification(u"System", u"Unbekannter Gast gekommen")
            else:
                if presenceState == PresenceHelper.STATE_MAYBE_PRESENT:
                    # check in 15 seconds again if there was any move events
                    self.confirmTimer = startTimer(self.log, 15,
                                                   self.confirmArriving)
        else:
            # move events during sleep, check function will be called during presence state update cycle
            if presenceState == PresenceHelper.STATE_SLEEPING:
                postUpdate("pOther_Presence_State",
                           PresenceHelper.STATE_MAYBE_SLEEPING)
            elif presenceState == PresenceHelper.STATE_MAYBE_SLEEPING:
                self.delayedSleepingCheck()
            elif presenceState == PresenceHelper.STATE_MAYBE_PRESENT and self.isConfirmed:
                self.delayedAwayCheck()
    def execute(self, module, input):
        itemName = input['event'].getItemName()
        itemState = input['event'].getItemState()

        # sometimes, phones are losing wifi connections because of their sleep mode
        if itemState == OFF:
            if itemLastChangeOlderThen(
                    "pGF_Corridor_Openingcontact_Door_State",
                    ZonedDateTime.now().minusMinutes(30)):
                self.skippedTimer[itemName] = startTimer(
                    self.log, 7200, self.process, args=[itemName,
                                                        itemState])  # 1 hour
                sendNotification(
                    u"System",
                    u"Delayed presence processing {} for {}".format(
                        itemState, itemName),
                    recipients=['bot_holger'])
                return
        else:
            if itemName in self.skippedTimer:
                self.skippedTimer[itemName].cancel()
                del self.skippedTimer[itemName]
                sendNotification(
                    u"System",
                    u"Cancel presence processing {} for {}".format(
                        itemState, itemName),
                    recipients=['bot_holger'])
                return

        self.process(itemName, itemState)
Example #3
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Notify") != ON:
            return

        state = getItemState("pOther_Presence_State").intValue()

        if state in [PresenceHelper.STATE_AWAY, PresenceHelper.STATE_SLEEPING]:
            itemName = input['event'].getItemName()
            item = getItem(itemName)

            location = self.getLocation(item)

            if "Door" in itemName:
                msg = u"Tür im {} {}".format(
                    location.getLabel(), u"offen" if
                    input['event'].getItemState() == OPEN else u"geschlossen")
            elif "Window" in itemName:
                msg = u"Fenster im {} {}".format(
                    location.getLabel(), u"offen" if
                    input['event'].getItemState() == OPEN else u"geschlossen")
            elif "Motiondetector" in itemName:
                if input['event'].getItemState() == CLOSED:
                    return

                # during sleep, ignore moving detection
                if state == PresenceHelper.STATE_SLEEPING:
                    return

                msg = u"Bewegung im {} erkannt".format(location.getLabel())

            #self.log.info(u"{} {} {} {}".format(group,itemName,item.getLabel(),location.getLabel()))

            sendNotification(u"Alarm", u"{}".format(msg))
    def execute(self, module, input):
        if itemStateOlderThen(
                "pOutdoor_Streedside_Gardendoor_Bell_Last_Change",
                ZonedDateTime.now().minusSeconds(30)):
            sendNotification("Klingel", "Es klingelt",
                             "https://smartmarvin.de/cameraStrasseImage")

        postUpdate("pOutdoor_Streedside_Gardendoor_Bell_Last_Change",
                   DateTimeType())
Example #5
0
 def execute(self, module, input):
     state = input['event'].getItemState()
     # self.log.info(u"tel 0: {}".format(state.getValue(0)))
     # self.log.info(u"tel 1: {}".format(state.getValue(1)))
     if type(state) is StringListType and itemStateOlderThen(
             "Gardendoor_Bell_Last_Change",
             getNow().minusSeconds(30)) and state.getValue(1) == '99999999':
         sendNotification("Klingel", "Es klingelt",
                          "https://bolle.haus/cameraStrasseImage")
         postUpdate("Gardendoor_Bell_Last_Change", DateTimeType())
Example #6
0
    def execute(self, module, input):

        #day = getItemState("pGF_Corridor_Garbage_Appointments_Begin_0")
        #info = getItemState("pGF_Corridor_Garbage_Appointments_Info_0")
        #self.log.info(u"{} {}".format(day,info))

        active = []

        if itemStateNewerThen("pGF_Corridor_Garbage_Appointments_Begin_0",
                              ZonedDateTime.now()) and itemStateOlderThen(
                                  "pGF_Corridor_Garbage_Appointments_Begin_0",
                                  ZonedDateTime.now().plusHours(12)):
            self.append(
                active,
                getItemState("pGF_Corridor_Garbage_Appointments_Info_0").
                toString().strip())

        if itemStateNewerThen("pGF_Corridor_Garbage_Appointments_Begin_1",
                              ZonedDateTime.now()) and itemStateOlderThen(
                                  "pGF_Corridor_Garbage_Appointments_Begin_1",
                                  ZonedDateTime.now().plusHours(12)):
            self.append(
                active,
                getItemState("pGF_Corridor_Garbage_Appointments_Info_1").
                toString().strip())

        if itemStateNewerThen("pGF_Corridor_Garbage_Appointments_Begin_2",
                              ZonedDateTime.now()) and itemStateOlderThen(
                                  "pGF_Corridor_Garbage_Appointments_Begin_2",
                                  ZonedDateTime.now().plusHours(12)):
            self.append(
                active,
                getItemState("pGF_Corridor_Garbage_Appointments_Info_2").
                toString().strip())

        if len(active) > 0:
            msg = ", ".join(active)
            sendNotification(u"Müllabholung", msg)
    def execute(self, module, input):
        group = "Fehler"
        active = []
        #url = None

        if getItemState("pIndoor_Roomba_status") != NULL and (
                getItemState("pIndoor_Roomba_status").toString() == "Stuck"
                or getItemState("pIndoor_Roomba_full") == ON):
            active.append("Roomba")

        if getItemState("pOutdoor_Mower_Status") != NULL and (
                getItemState("pOutdoor_Mower_Status").intValue() == 7
                or getItemState("pOutdoor_Mower_Status").intValue() == 8):
            active.append("Mower")
            #url = "https://smartmarvin.de/cameraAutomowerImage"

        if len(active) == 0:
            active.append("Alles ok")
            group = "Info"

        msg = ", ".join(active)

        if postUpdateIfChanged("pOther_State_Message_Robot", msg):
            sendNotification("Roboter " + group, msg)
    def process(self, itemName, itemState):
        presenceState = getItemState("pOther_Presence_State").intValue()

        #sendNotificationToAllAdmins(u"{}".format(itemName), u"{}".format(itemState))

        holgerPhone = itemState if itemName == "pOther_Presence_Holger_State" else getItemState(
            "pOther_Presence_Holger_State")
        sandraPhone = itemState if itemName == "pOther_Presence_Sandra_State" else getItemState(
            "pOther_Presence_Sandra_State")

        bot = PresenceHelper.getRecipientByStateItem(itemName)

        if holgerPhone == ON or sandraPhone == ON:
            # only possible if we are away
            if presenceState in [
                    PresenceHelper.STATE_AWAY,
                    PresenceHelper.STATE_MAYBE_PRESENT
            ]:
                postUpdate("pOther_Presence_State",
                           PresenceHelper.STATE_PRESENT)
        else:
            # only possible if we are present and not sleeping
            if presenceState in [
                    PresenceHelper.STATE_MAYBE_PRESENT,
                    PresenceHelper.STATE_PRESENT
            ]:
                postUpdate("pOther_Presence_State", PresenceHelper.STATE_AWAY)

        if itemState == ON:
            sendNotification(u"System", u"Willkommen", recipients=[bot])
        else:
            if holgerPhone == OFF and sandraPhone == OFF:
                lightMsg = u" - LICHT an" if getItemState(
                    "gIndoor_Lights") != OFF else u""
                windowMsg = u" - FENSTER offen" if getItemState(
                    "gOpeningcontacts") != CLOSED else u""
                sendNotification(u"System",
                                 u"Auf Wiedersehen{}{}".format(
                                     lightMsg, windowMsg),
                                 recipients=[bot])
            else:
                sendNotification(u"System",
                                 u"Auf Wiedersehen",
                                 recipients=[bot])
Example #9
0
 def execute(self, module, input):
     sendNotification("Roomba", u"Behälter ist voll")
 def notify(self, state):
     self.checkTimer = None
     sendNotification(
         u"Waschmaschine", u"Wäsche ist fertig"
         if state else u"Wäsche ist wahrscheinlich fertig")
Example #11
0
 def notify(self, state):
     self.checkTimer = None
     sendNotification(u"Geschirrspüler",
                      u"Geschirr ist fertig"
                      if state else u"Geschirr ist wahrscheinlich fertig",
                      recipients=PresenceHelper.getPresentRecipients())
Example #12
0
 def execute(self, module, input):
     sendNotification(
         "Roomba",
         getItemState("pIndoor_Roomba_StatusFormatted").toString())
 def execute(self, module, input):
     sendNotification(u"Kaffeemaschine",
                      u"Bohnen nachfüllen",
                      recipients=PresenceHelper.getPresentRecipients())
 def execute(self, module, input):
     sendNotification(u"Kaffeemaschine",
                      u"Auffangschale leeren",
                      recipients=PresenceHelper.getPresentRecipients())
 def execute(self, module, input):
     sendNotification("Alarm", u"Rauchmelder")
Example #16
0
    def process(self, recipients):
        now = ZonedDateTime.now()

        weatherAvgTemperature = getItemState(
            "pOutdoor_Weather_Current_Temperature_Avg").floatValue()

        room1Temperature = getItemState(
            "pGF_Livingroom_Air_Sensor_Temperature_Value").floatValue()
        room2Temperature = getItemState(
            "pFF_Bedroom_Air_Sensor_Temperature_Value").floatValue()

        # if temperature difference
        if weatherAvgTemperature <= room1Temperature or weatherAvgTemperature <= room2Temperature:
            self.log.info(u"PRECONDITION not fit ({} {} {})".format(
                weatherAvgTemperature, room1Temperature, room2Temperature))
            return

        gardenTemp0, gardenTemp0Min, gardenTemp0Max = getStableMinMaxItemState(
            now, "pOutdoor_WeatherStation_Temperature", 15)
        gardenTemp15, gardenTemp15Min, gardenTemp15Max = getStableMinMaxItemState(
            now.minusMinutes(15), "pOutdoor_WeatherStation_Temperature", 30)
        gardenTemp45, gardenTemp45Min, gardenTemp45Max = getStableMinMaxItemState(
            now.minusMinutes(45), "pOutdoor_WeatherStation_Temperature", 30)

        gardenTemp0 = round(gardenTemp0, 1)
        gardenTemp15 = round(gardenTemp15, 1)
        gardenTemp45 = round(gardenTemp45, 1)

        if gardenTemp0 > gardenTemp15 > gardenTemp45:
            direction = 1
        elif gardenTemp0 < gardenTemp15 < gardenTemp45:
            direction = -1
        else:
            if self.lastDirection is not None:
                direction = self.lastDirection
                if direction == 1:
                    if not (gardenTemp0 >= gardenTemp15 >= gardenTemp45):
                        direction = 0
                elif direction == -1:
                    if not (gardenTemp0 <= gardenTemp15 <= gardenTemp45):
                        direction = 0
            else:
                direction = 0

        self.log.info(
            u"GARDEN - Temp0: {}, Temp0Max: {}, Temp15: {}, Temp45: {}".format(
                gardenTemp0, gardenTemp0Max, gardenTemp15, gardenTemp45))

        gfShouldOpen = self.getOpenRequest(
            now, gardenTemp0, gardenTemp0Max, direction,
            "pGF_Livingroom_Air_Sensor_Temperature_Value",
            self.lastGFShouldOpen)
        gfIsOpen = self.getOpenState(
            "gGF_Sensor_Window",
            ["pGF_Livingroom_Openingcontact_Window_Terrace_State"])

        ffShouldOpen = self.getOpenRequest(
            now, gardenTemp0, gardenTemp0Max, direction,
            "pFF_Bedroom_Air_Sensor_Temperature_Value", self.lastFFShouldOpen)
        ffIsOpen = self.getOpenState("gFF_Sensor_Window")

        if (self.lastGFShouldOpen != gfShouldOpen and gfShouldOpen != gfIsOpen
            ) or (self.lastFFShouldOpen != ffShouldOpen
                  and ffShouldOpen != ffIsOpen):
            recipients = PresenceHelper.getPresentRecipients()

        self.log.info(
            u"STATE - gfShouldOpen: {}, gfIsOpen: {}, ffShouldOpen: {}, ffIsOpen: {}, direction: {}"
            .format(gfShouldOpen, gfIsOpen, ffShouldOpen, ffIsOpen, direction))

        if recipients is not None:
            actions = {"OPEN": [], "CLOSE": []}
            if gfShouldOpen != gfIsOpen:
                if gfShouldOpen:
                    actions["OPEN"].append("EG")
                else:
                    actions["CLOSE"].append("EG")
            if ffShouldOpen != ffIsOpen:
                if ffShouldOpen:
                    actions["OPEN"].append("OG")
                else:
                    actions["CLOSE"].append("OG")

            msg = []
            if len(actions["OPEN"]) == 2:
                msg.append(u"Alle Fenster auf")
            elif len(actions["CLOSE"]) == 2:
                msg.append(u"Alle Fenster zu")
            else:
                if len(actions["OPEN"]) == 1:
                    msg.append(u"{} Fenster auf".format(actions["OPEN"][0]))
                if len(actions["CLOSE"]) == 1:
                    msg.append(u"{} Fenster zu".format(actions["CLOSE"][0]))

            if len(msg) > 0:
                msg = u" und ".join(msg)

                self.log.info(u"MSG: {}".format(msg))

                # we are not sleeping
                if getItemState("pOther_Presence_State").intValue() not in [
                        PresenceHelper.STATE_MAYBE_SLEEPING,
                        PresenceHelper.STATE_SLEEPING
                ]:
                    # initial debug
                    if self.lastDirection is None:
                        recipients = ["bot_holger"]
                    sendNotification(u"Lüften", msg, recipients=recipients)

        self.lastDirection = direction
        self.lastGFShouldOpen = gfShouldOpen
        self.lastFFShouldOpen = ffShouldOpen
Example #17
0
 def execute(self, module, input):
     sendNotification("Roomba", u"Es ist ein Fehler aufgetreten")
 def setAway(self, isFallback):
     postUpdateIfChanged("pOther_Presence_State", PresenceHelper.STATE_AWAY)
     sendNotification(
         u"System", u"Unbekannter Gast {}".format(
             u"verschwunden" if isFallback else u"gegangen"))
 def wakeup(self):
     postUpdate("pOther_Presence_State", PresenceHelper.STATE_PRESENT)
     sendNotification(u"System", u"Guten Morgen")
Example #20
0
 def execute(self, module, input):
     itemName = input['event'].getItemName()
     itemState = input['event'].getItemState()
     
     sendNotification(u"{}".format(itemName), u"{}".format(itemState), recipients = ["bot_markus"])