mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix bug in rfxtrx for int device id (#2497)
This commit is contained in:
parent
6d60287455
commit
09a4336bc5
@ -66,6 +66,9 @@ def _valid_device(value, device_type):
|
|||||||
key = device.get('packetid')
|
key = device.get('packetid')
|
||||||
device.pop('packetid')
|
device.pop('packetid')
|
||||||
|
|
||||||
|
if not len(key) % 2 == 0:
|
||||||
|
key = '0' + key
|
||||||
|
|
||||||
if get_rfx_object(key) is None:
|
if get_rfx_object(key) is None:
|
||||||
raise vol.Invalid('Rfxtrx device {} is invalid: '
|
raise vol.Invalid('Rfxtrx device {} is invalid: '
|
||||||
'Invalid device id for {}'.format(key, value))
|
'Invalid device id for {}'.format(key, value))
|
||||||
@ -160,7 +163,11 @@ def get_rfx_object(packetid):
|
|||||||
"""Return the RFXObject with the packetid."""
|
"""Return the RFXObject with the packetid."""
|
||||||
import RFXtrx as rfxtrxmod
|
import RFXtrx as rfxtrxmod
|
||||||
|
|
||||||
binarypacket = bytearray.fromhex(packetid)
|
try:
|
||||||
|
binarypacket = bytearray.fromhex(packetid)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
pkt = rfxtrxmod.lowlevel.parse(binarypacket)
|
pkt = rfxtrxmod.lowlevel.parse(binarypacket)
|
||||||
if pkt is None:
|
if pkt is None:
|
||||||
return None
|
return None
|
||||||
|
@ -34,6 +34,17 @@ class TestSwitchRfxtrx(unittest.TestCase):
|
|||||||
rfxtrx_core.ATTR_FIREEVENT: True}
|
rfxtrx_core.ATTR_FIREEVENT: True}
|
||||||
}}}))
|
}}}))
|
||||||
|
|
||||||
|
def test_valid_config_int_device_id(self):
|
||||||
|
"""Test configuration."""
|
||||||
|
self.assertTrue(_setup_component(self.hass, 'switch', {
|
||||||
|
'switch': {'platform': 'rfxtrx',
|
||||||
|
'automatic_add': True,
|
||||||
|
'devices':
|
||||||
|
{'710000141010170': {
|
||||||
|
'name': 'Test',
|
||||||
|
rfxtrx_core.ATTR_FIREEVENT: True}
|
||||||
|
}}}))
|
||||||
|
|
||||||
def test_invalid_config1(self):
|
def test_invalid_config1(self):
|
||||||
self.assertFalse(_setup_component(self.hass, 'switch', {
|
self.assertFalse(_setup_component(self.hass, 'switch', {
|
||||||
'switch': {'platform': 'rfxtrx',
|
'switch': {'platform': 'rfxtrx',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user