'Module for managing a garage door.'
from time import sleep
import automationhat

DOOR_CLOSED = 0
DOOR_OPEN = 1


class GarageDoor(object):
    'Class for controlling a garage door.'

    def __init__(self, name, state_pin, trigger_delay=0.500):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name


    def trigger(self):
        'Triggers the door relay to open or close it.'
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()


    @property
    def state(self):
        'Return the current state of the door.'
        if automationhat.input[self.state_pin - 1].read() == 1:
            return "closed"
        else:
            return "open"


    @state.setter
    def state(self, value):
        raise AttributeError('can\'t set attribute')


    def open(self):
        'If the door is closed, trigger opening it.'
        if self.state == DOOR_CLOSED:
            self.trigger()


    def close(self):
        'If the door is open, trigger closing it.'
        if self.state == DOOR_OPEN:
            self.trigger()
2cb00363944564e9046c3c3104ffde0337aa3087
<mask token>


class GarageDoor(object):
    <mask token>

    def __init__(self, name, state_pin, trigger_delay=0.5):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name

    def trigger(self):
        """Triggers the door relay to open or close it."""
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()

    @property
    def state(self):
        """Return the current state of the door."""
        if automationhat.input[self.state_pin - 1].read() == 1:
            return 'closed'
        else:
            return 'open'

    @state.setter
    def state(self, value):
        raise AttributeError("can't set attribute")

    def open(self):
        """If the door is closed, trigger opening it."""
        if self.state == DOOR_CLOSED:
            self.trigger()

    def close(self):
        """If the door is open, trigger closing it."""
        if self.state == DOOR_OPEN:
            self.trigger()

<mask token>


class GarageDoor(object):
    """Class for controlling a garage door."""

    def __init__(self, name, state_pin, trigger_delay=0.5):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name

    def trigger(self):
        """Triggers the door relay to open or close it."""
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()

    @property
    def state(self):
        """Return the current state of the door."""
        if automationhat.input[self.state_pin - 1].read() == 1:
            return 'closed'
        else:
            return 'open'

    @state.setter
    def state(self, value):
        raise AttributeError("can't set attribute")

    def open(self):
        """If the door is closed, trigger opening it."""
        if self.state == DOOR_CLOSED:
            self.trigger()

    def close(self):
        """If the door is open, trigger closing it."""
        if self.state == DOOR_OPEN:
            self.trigger()

<mask token>
DOOR_CLOSED = 0
DOOR_OPEN = 1


class GarageDoor(object):
    """Class for controlling a garage door."""

    def __init__(self, name, state_pin, trigger_delay=0.5):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name

    def trigger(self):
        """Triggers the door relay to open or close it."""
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()

    @property
    def state(self):
        """Return the current state of the door."""
        if automationhat.input[self.state_pin - 1].read() == 1:
            return 'closed'
        else:
            return 'open'

    @state.setter
    def state(self, value):
        raise AttributeError("can't set attribute")

    def open(self):
        """If the door is closed, trigger opening it."""
        if self.state == DOOR_CLOSED:
            self.trigger()

    def close(self):
        """If the door is open, trigger closing it."""
        if self.state == DOOR_OPEN:
            self.trigger()

<mask token>
from time import sleep
import automationhat
DOOR_CLOSED = 0
DOOR_OPEN = 1


class GarageDoor(object):
    """Class for controlling a garage door."""

    def __init__(self, name, state_pin, trigger_delay=0.5):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name

    def trigger(self):
        """Triggers the door relay to open or close it."""
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()

    @property
    def state(self):
        """Return the current state of the door."""
        if automationhat.input[self.state_pin - 1].read() == 1:
            return 'closed'
        else:
            return 'open'

    @state.setter
    def state(self, value):
        raise AttributeError("can't set attribute")

    def open(self):
        """If the door is closed, trigger opening it."""
        if self.state == DOOR_CLOSED:
            self.trigger()

    def close(self):
        """If the door is open, trigger closing it."""
        if self.state == DOOR_OPEN:
            self.trigger()

'Module for managing a garage door.'
from time import sleep
import automationhat

DOOR_CLOSED = 0
DOOR_OPEN = 1


class GarageDoor(object):
    'Class for controlling a garage door.'

    def __init__(self, name, state_pin, trigger_delay=0.500):
        self.state_pin = state_pin
        self.trigger_delay = trigger_delay
        self.name = name


    def trigger(self):
        'Triggers the door relay to open or close it.'
        automationhat.relay.on()
        sleep(self.trigger_delay)
        automationhat.relay.off()


    @property
    def state(self):
        'Return the current state of the door.'
        if automationhat.input[self.state_pin - 1].read() == 1:
            return "closed"
        else:
            return "open"


    @state.setter
    def state(self, value):
        raise AttributeError('can\'t set attribute')


    def open(self):
        'If the door is closed, trigger opening it.'
        if self.state == DOOR_CLOSED:
            self.trigger()


    def close(self):
        'If the door is open, trigger closing it.'
        if self.state == DOOR_OPEN:
            self.trigger()