Move imports to top for enocean (#29451)
parent
cdf53aed93
commit
5586f40ab0
|
@ -1,11 +1,14 @@
|
||||||
"""Support for EnOcean devices."""
|
"""Support for EnOcean devices."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from enocean.communicators.serialcommunicator import SerialCommunicator
|
||||||
|
from enocean.protocol.packet import Packet, RadioPacket
|
||||||
|
from enocean.utils import combine_hex
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_DEVICE
|
from homeassistant.const import CONF_DEVICE
|
||||||
from homeassistant.helpers.entity import Entity
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -34,7 +37,6 @@ class EnOceanDongle:
|
||||||
|
|
||||||
def __init__(self, hass, ser):
|
def __init__(self, hass, ser):
|
||||||
"""Initialize the EnOcean dongle."""
|
"""Initialize the EnOcean dongle."""
|
||||||
from enocean.communicators.serialcommunicator import SerialCommunicator
|
|
||||||
|
|
||||||
self.__communicator = SerialCommunicator(port=ser, callback=self.callback)
|
self.__communicator = SerialCommunicator(port=ser, callback=self.callback)
|
||||||
self.__communicator.start()
|
self.__communicator.start()
|
||||||
|
@ -53,7 +55,6 @@ class EnOceanDongle:
|
||||||
This is the callback function called by python-enocan whenever there
|
This is the callback function called by python-enocan whenever there
|
||||||
is an incoming packet.
|
is an incoming packet.
|
||||||
"""
|
"""
|
||||||
from enocean.protocol.packet import RadioPacket
|
|
||||||
|
|
||||||
if isinstance(packet, RadioPacket):
|
if isinstance(packet, RadioPacket):
|
||||||
_LOGGER.debug("Received radio packet: %s", packet)
|
_LOGGER.debug("Received radio packet: %s", packet)
|
||||||
|
@ -76,7 +77,6 @@ class EnOceanDevice(Entity):
|
||||||
|
|
||||||
def _message_received_callback(self, packet):
|
def _message_received_callback(self, packet):
|
||||||
"""Handle incoming packets."""
|
"""Handle incoming packets."""
|
||||||
from enocean.utils import combine_hex
|
|
||||||
|
|
||||||
if packet.sender_int == combine_hex(self.dev_id):
|
if packet.sender_int == combine_hex(self.dev_id):
|
||||||
self.value_changed(packet)
|
self.value_changed(packet)
|
||||||
|
@ -86,7 +86,6 @@ class EnOceanDevice(Entity):
|
||||||
|
|
||||||
def send_command(self, data, optional, packet_type):
|
def send_command(self, data, optional, packet_type):
|
||||||
"""Send a command via the EnOcean dongle."""
|
"""Send a command via the EnOcean dongle."""
|
||||||
from enocean.protocol.packet import Packet
|
|
||||||
|
|
||||||
packet = Packet(packet_type, data=data, optional=optional)
|
packet = Packet(packet_type, data=data, optional=optional)
|
||||||
self.hass.helpers.dispatcher.dispatcher_send(SIGNAL_SEND_MESSAGE, packet)
|
self.hass.helpers.dispatcher.dispatcher_send(SIGNAL_SEND_MESSAGE, packet)
|
||||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEVICE_CLASS_HUMIDITY,
|
DEVICE_CLASS_HUMIDITY,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue