コード例 #1
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)
        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        self.seasons = {}

        for season in self.extendedargs.seasons:
            self.seasons[season.name] = season

            self.log(season.name, level=LEVEL)

            start, end = self.evaluateDates(season.start.date, season.end.date)
            date_format = '%m-%d-%Y'
            self.log(' start: {}'.format(start.strftime(date_format)),
                     level=LEVEL)
            self.log(' end: {}'.format(end.strftime(date_format)), level=LEVEL)

            self.log(' currently {}'.format(self.seasonStatus(season)),
                     level=LEVEL)

            time_format = '%I:%M %p'
            self.log(' lights on at {}'.format(
                str(season.turn_on.time.strftime(time_format))),
                     level=LEVEL)
            self.run_daily(self.run_turn_on,
                           season.turn_on.time,
                           season=season.name)
            self.log(' lights off at {}'.format(
                str(season.turn_off.time.strftime(time_format))),
                     level=LEVEL)
            self.run_daily(self.run_turn_off,
                           season.turn_off.time,
                           season=season.name)
コード例 #2
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        self.run_at_sunset(self.entities_on)
        self.run_at_sunrise(self.entities_off)
コード例 #3
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        for switch in self.extendedargs.switches:
            self.listen_state(self.turn_on_after_sun_down,
                              entity=switch.entity.entity_id,
                              objects=switch.entities)
コード例 #4
0
    def initialize(self):

        self.timers = {}
        self.extendedargs = extenddict(self.args)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        for multisensor in self.extendedargs.multisensors:
            self.listen_state(self.track_multisensor_movement,
                              entity=multisensor.entity.entity_id,
                              multisensor=multisensor)
コード例 #5
0
    def initialize(self):
        self.log(type(self.args), level=LEVEL)
        self.args = extenddict(self.args)

        for line in self.args.toLines():
            self.log(line, level=LEVEL)

        self.minimotes = {}
        for minimote in self.args.minimotes:
            self.minimotes[minimote.entity.entity_id] = minimote

        self.listen_event(self.minimote_button_evt, "zwave.scene_activated")
コード例 #6
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        self.log(self.extendedargs, level=LEVEL)
        
        self.input_select = self.extendedargs.input_select
        
        self.media_players = {}
        for i, player in enumerate(self.extendedargs.media_players):
            self.listen_state(self.track_player_state,
                entity = player.entity.entity_id, player = player)
            self.media_players['{}'.format(i+1)] = player
コード例 #7
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        self.log(self.extendedargs, level=LEVEL)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        for player in self.extendedargs.media_players:

            self.listen_state(self.track_player_state,
                              entity=player.entity.entity_id,
                              player=player)
コード例 #8
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        for player in self.extendedargs.media_players:

            self.listen_state(self.track_volume_from_player, 
                entity=player.entity.entity_id, input_number=player.input_number)

            self.listen_state(self.track_volume_from_input_number, 
                entity=player.input_number.entity_id, media_player=player.entity)
コード例 #9
0
    def initialize(self):
        self.extendedargs = extenddict(self.args)

        self.log(self.extendedargs, level=LEVEL)

        for line in self.extendedargs.toLines():
            self.log(line, level=LEVEL)

        # object for tracking who's home based on device trackers.
        self.people = PeopleTracker(self, self.extendedargs.device_trackers)

        company = self.extendedargs.company
        self.people.setcompanystatus(company)
        self.people.update()

        self.listen_state(self.track_company,
                          entity=company.entity_id,
                          company=company)

        # read/write database for states persisiting during shutdown/restart.
        self.database = StateDatabase(RESTORE_LOCATION)

        self.timers = {}

        self.log(self.people.log, level=LEVEL)

        # managers for restoring lights to previous state after a door opens.
        self.managers = RestoreStateManager()

        for sensor in self.extendedargs.door_sensors:

            self.managers.add_manager(sensor.entity.entity_id)

            self.listen_state(self.door_tracker,
                              entity=sensor.entity.entity_id,
                              sensor=sensor)

            #Setup new state object
            entity_id = 'sensor.{}_message'.format(sensor.entity.object_id)
            state = self.database.read(entity_id)
            friendly_name = '{} User'.format(
                self.get_state(sensor.entity.entity_id,
                               attribute='friendly_name'))
            attributes = {'friendly_name': friendly_name, 'icon': 'mdi:door'}

            # set the state inside home assistant.
            self.set_state(entity_id, state=state, attributes=attributes)