<commit_before># coding=utf-8

from utils import SensorConsumerBase
import sys
import datetime


class Door(SensorConsumerBase):

    def __init__(self):
        SensorConsumerBase.__init__(self)
        self.notification = None
        self.delete_notification("door")
        self.door_open_elapsed_since = None

    def run(self):
        self.subscribe("door-pubsub", self.pubsub_callback)

    def pubsub_callback(self, data):
        if "action" in data:
            return

        influx_data = {
            "measurement": "door",
            "time": datetime.datetime.utcnow().isoformat() + "Z",
            "tags": {
                "location": "door",
            },
            "fields": data["data"],
        }
        self.insert_into_influx([influx_data])

        if data["data"]["door_outer_open"]:
            if not self.door_open_elapsed_since:
                self.door_open_elapsed_since = datetime.datetime.now()
            notification = {<commit_msg>Trigger lights based on door state<commit_after># coding=utf-8

from utils import SensorConsumerBase
import sys
import datetime
import json


class Door(SensorConsumerBase):

    def __init__(self):
        SensorConsumerBase.__init__(self)
        self.notification = None
        self.delete_notification("door")
        self.door_open_elapsed_since = None

        self.outer_door_state = None
        self.inner_door_state = None

    def run(self):
        self.subscribe("door-pubsub", self.pubsub_callback)

    def pubsub_callback(self, data):
        if "action" in data:
            return

        influx_data = {
            "measurement": "door",
            "time": datetime.datetime.utcnow().isoformat() + "Z",
            "tags": {
                "location": "door",
            },
            "fields": data["data"],
        }
        self.insert_into_influx([influx_data])

        if self.outer_door_state is not None:
            if self.outer_door_state != data["data"]["door_outer_open"]:
                self.redis_instance.publish("lightcontrol-triggers-pubsub", json.dumps({"key": "outer-door", "trigger": "switch", "open": data["data"]["door_outer_open"]}))
        if self.inner_door_state is not None:
            if self.inner_door_state != data["data"]["door_inner_open"]:
                self.redis_instance.publish("lightcontrol-triggers-pubsub", json.dumps({"key": "inner-door", "trigger": "switch", "open": data["data"]["door_inner_open"]}))

        self.outer_door_state = data["data"]["door_outer_open"]
        self.inner_door_state = data["data"]["door_inner_open"]

        if data["data"]["door_outer_open"]:
            if not self.door_open_elapsed_since:
                self.door_open_elapsed_since = datetime.datetime.now()
            notification = {
{'fraction_non_alphanumeric': 0.12463976945244956, 'fraction_numerical': 0.0007204610951008645, 'mean_word_length': 2.5107458912768648, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '628990', 'n_tokens_mistral': 814, 'n_tokens_neox': 812, 'n_words': 149}