def run(self):
        """Event thread."""

        while True:
            self._panel = AquaLogic()
            self._panel.connect(self._host, self._port)
            self._panel.process(self.data_changed)

            if self._shutdown:
                return

            _LOGGER.error("Connection to %s:%d lost", self._host, self._port)
            time.sleep(RECONNECT_INTERVAL.total_seconds())
Example #2
0
class AquaLogicProcessor(threading.Thread):
    """AquaLogic event processor thread."""

    def __init__(self, hass, host, port):
        """Initialize the data object."""
        super().__init__(daemon=True)
        self._hass = hass
        self._host = host
        self._port = port
        self._shutdown = False
        self._panel = None

    def start_listen(self, event):
        """Start event-processing thread."""
        _LOGGER.debug("Event processing thread started")
        self.start()

    def shutdown(self, event):
        """Signal shutdown of processing event."""
        _LOGGER.debug("Event processing signaled exit")
        self._shutdown = True

    def data_changed(self, panel):
        """Aqualogic data changed callback."""
        self._hass.helpers.dispatcher.dispatcher_send(UPDATE_TOPIC)

    def run(self):
        """Event thread."""
        from aqualogic.core import AquaLogic

        while True:
            self._panel = AquaLogic()
            self._panel.connect(self._host, self._port)
            self._panel.process(self.data_changed)

            if self._shutdown:
                return

            _LOGGER.error("Connection to %s:%d lost",
                          self._host, self._port)
            time.sleep(RECONNECT_INTERVAL.seconds)

    @property
    def panel(self):
        """Retrieve the AquaLogic object."""
        return self._panel
Example #3
0
 def test_spa(self):
     aq = AquaLogic()
     aq.connect_io(FileIO('tests/data/spa_on.bin'))
     aq.process(self.data_changed)
     assert aq.is_metric
     assert aq.air_temp == -6
     assert aq.pool_temp == None
     assert aq.spa_temp == -7
     assert aq.pool_chlorinator == None
     assert aq.spa_chlorinator == 3
     assert aq.salt_level == 3.1
     assert not aq.get_state(States.POOL)
     assert aq.get_state(States.FILTER)
     assert aq.get_state(States.SPA)
Example #4
0
class AquaLogicProcessor(threading.Thread):
    """AquaLogic event processor thread."""

    def __init__(self, hass, host, port):
        """Initialize the data object."""
        super().__init__(daemon=True)
        self._hass = hass
        self._host = host
        self._port = port
        self._shutdown = False
        self._panel = None

    def start_listen(self, event):
        """Start event-processing thread."""
        _LOGGER.debug("Event processing thread started")
        self.start()

    def shutdown(self, event):
        """Signal shutdown of processing event."""
        _LOGGER.debug("Event processing signaled exit")
        self._shutdown = True

    def data_changed(self, panel):
        """Aqualogic data changed callback."""
        self._hass.helpers.dispatcher.dispatcher_send(UPDATE_TOPIC)

    def run(self):
        """Event thread."""
        from aqualogic.core import AquaLogic

        while True:
            self._panel = AquaLogic()
            self._panel.connect(self._host, self._port)
            self._panel.process(self.data_changed)

            if self._shutdown:
                return

            _LOGGER.error("Connection to %s:%d lost", self._host, self._port)
            time.sleep(RECONNECT_INTERVAL.seconds)

    @property
    def panel(self):
        """Retrieve the AquaLogic object."""
        return self._panel
    def run(self):
        """Event thread."""
        from aqualogic.core import AquaLogic

        while True:
            self._panel = AquaLogic()
            self._panel.connect(self._host, self._port)
            self._panel.process(self.data_changed)

            if self._shutdown:
                return

            _LOGGER.error("Connection to %s:%d lost", self._host, self._port)
            time.sleep(RECONNECT_INTERVAL.seconds)
Example #6
0
 def test_pool(self):
     reader = FileIO('tests/data/pool_on.bin')
     aq = AquaLogic(reader, None)
     aq.process(self.data_changed)
     # Yes it was cold out when I grabbed this data
     assert aq.is_metric
     assert aq.air_temp == -6
     assert aq.pool_temp == -7
     assert aq.spa_temp == None
     assert aq.pool_chlorinator == None
     assert aq.spa_chlorinator == 3
     assert aq.salt_level == 3.1
     assert aq.get_state(States.POOL)
     assert aq.get_state(States.FILTER)
     assert not aq.get_state(States.SPA)