mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Log RFXCOM events
This commit is contained in:
parent
db509ccf18
commit
7f71706f08
@ -23,6 +23,7 @@ rfxtrx:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/' +
|
REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/' +
|
||||||
@ -43,6 +44,13 @@ def setup(hass, config):
|
|||||||
def handle_receive(event):
|
def handle_receive(event):
|
||||||
""" Callback all subscribers for RFXtrx gateway. """
|
""" Callback all subscribers for RFXtrx gateway. """
|
||||||
|
|
||||||
|
# Log RFXCOM event
|
||||||
|
entity_id = slugify(event.device.id_string.lower())
|
||||||
|
packet_id = "".join("{0:02x}".format(x) for x in event.data)
|
||||||
|
entity_name = "%(entity_id)s : %(packet_id)s" % locals()
|
||||||
|
_LOGGER.info("Receive RFXCOM event from %s => %s" % (event.device, entity_name))
|
||||||
|
|
||||||
|
# Callback to HA registered components
|
||||||
for subscriber in RECEIVED_EVT_SUBSCRIBERS:
|
for subscriber in RECEIVED_EVT_SUBSCRIBERS:
|
||||||
subscriber(event)
|
subscriber(event)
|
||||||
|
|
||||||
@ -68,6 +76,12 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def getRFXObject(packetid):
|
def getRFXObject(packetid):
|
||||||
""" return the RFXObject with the packetid"""
|
""" return the RFXObject with the packetid"""
|
||||||
|
try:
|
||||||
|
import RFXtrx as rfxtrxmod
|
||||||
|
except ImportError:
|
||||||
|
_LOGGER.exception("Failed to import rfxtrx")
|
||||||
|
return False
|
||||||
|
|
||||||
binarypacket = bytearray.fromhex(packetid)
|
binarypacket = bytearray.fromhex(packetid)
|
||||||
|
|
||||||
pkt = rfxtrxmod.lowlevel.parse(binarypacket)
|
pkt = rfxtrxmod.lowlevel.parse(binarypacket)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user