Merge pull request #1466 from balloob/tests_rfxtrx_device
Tests rfxtrx device
This commit is contained in:
commit
88c834fdd3
7 files changed
+585
-17
No files matched your search
@@ -164,18 +164,16 @@ class RfxtrxLight(Light):
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||
if not self._event:
|
||||
return
|
||||
|
||||
if brightness is None:
|
||||
self._brightness = 100
|
||||
self._brightness = 255
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._event.device.send_on(rfxtrx.RFXOBJECT.transport)
|
||||
else:
|
||||
self._brightness = ((brightness + 4) * 100 // 255 - 1)
|
||||
self._brightness = brightness
|
||||
_brightness = (brightness * 100 // 255)
|
||||
for _ in range(self.signal_repetitions):
|
||||
self._event.device.send_dim(rfxtrx.RFXOBJECT.transport,
|
||||
self._brightness)
|
||||
|
||||
self._brightness = (self._brightness * 255 // 100)
|
||||
_brightness)
|
||||
self._state = True
|
||||
self.update_ha_state()
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import logging
|
||||
|
||||
from homeassistant.util import slugify
|
||||
|
||||
REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/0.4.zip' +
|
||||
'#pyRFXtrx==0.4']
|
||||
REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/' +
|
||||
'archive/0.5.zip#pyRFXtrx==0.5']
|
||||
|
||||
DOMAIN = "rfxtrx"
|
||||
|
||||
@@ -22,6 +22,7 @@ ATTR_NAME = 'name'
|
||||
ATTR_PACKETID = 'packetid'
|
||||
ATTR_FIREEVENT = 'fire_event'
|
||||
ATTR_DATA_TYPE = 'data_type'
|
||||
ATTR_DUMMY = "dummy"
|
||||
|
||||
EVENT_BUTTON_PRESSED = 'button_pressed'
|
||||
|
||||
@@ -37,7 +38,6 @@ def setup(hass, config):
|
||||
# Declare the Handle event
|
||||
def handle_receive(event):
|
||||
""" Callback all subscribers for RFXtrx gateway. """
|
||||
|
||||
# Log RFXCOM event
|
||||
if not event.device.id_string:
|
||||
return
|
||||
@@ -58,16 +58,22 @@ def setup(hass, config):
|
||||
global RFXOBJECT
|
||||
|
||||
if ATTR_DEVICE not in config[DOMAIN]:
|
||||
_LOGGER.exception(
|
||||
"can found device parameter in %s YAML configuration section",
|
||||
_LOGGER.error(
|
||||
"can not find device parameter in %s YAML configuration section",
|
||||
DOMAIN
|
||||
)
|
||||
return False
|
||||
|
||||
device = config[DOMAIN][ATTR_DEVICE]
|
||||
debug = config[DOMAIN].get(ATTR_DEBUG, False)
|
||||
dummy_connection = config[DOMAIN].get(ATTR_DUMMY, False)
|
||||
|
||||
RFXOBJECT = rfxtrxmod.Core(device, handle_receive, debug=debug)
|
||||
if dummy_connection:
|
||||
RFXOBJECT =\
|
||||
rfxtrxmod.Core(device, handle_receive, debug=debug,
|
||||
transport_protocol=rfxtrxmod.DummyTransport2)
|
||||
else:
|
||||
RFXOBJECT = rfxtrxmod.Core(device, handle_receive, debug=debug)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in new issue
Block a user