Add hass to rfxtrx object (#6844)
This commit is contained in:
parent
61196b1c83
commit
526abdd329
4 changed files with 10 additions and 8 deletions
|
@ -16,7 +16,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
"""Set up the RFXtrx cover."""
|
||||
import RFXtrx as rfxtrxmod
|
||||
|
||||
covers = rfxtrx.get_devices_from_config(config, RfxtrxCover)
|
||||
covers = rfxtrx.get_devices_from_config(config, RfxtrxCover, hass)
|
||||
add_devices_callback(covers)
|
||||
|
||||
def cover_update(event):
|
||||
|
@ -26,7 +26,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
not event.device.known_to_be_rollershutter:
|
||||
return
|
||||
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxCover)
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxCover, hass)
|
||||
if new_device:
|
||||
add_devices_callback([new_device])
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
"""Set up the RFXtrx platform."""
|
||||
import RFXtrx as rfxtrxmod
|
||||
|
||||
lights = rfxtrx.get_devices_from_config(config, RfxtrxLight)
|
||||
lights = rfxtrx.get_devices_from_config(config, RfxtrxLight, hass)
|
||||
add_devices(lights)
|
||||
|
||||
def light_update(event):
|
||||
|
@ -32,7 +32,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
not event.device.known_to_be_dimmable:
|
||||
return
|
||||
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxLight)
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxLight, hass)
|
||||
if new_device:
|
||||
add_devices([new_device])
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ def get_rfx_object(packetid):
|
|||
return obj
|
||||
|
||||
|
||||
def get_devices_from_config(config, device):
|
||||
def get_devices_from_config(config, device, hass):
|
||||
"""Read rfxtrx configuration."""
|
||||
signal_repetitions = config[CONF_SIGNAL_REPETITIONS]
|
||||
|
||||
|
@ -209,12 +209,13 @@ def get_devices_from_config(config, device):
|
|||
|
||||
new_device = device(entity_info[ATTR_NAME], event, datas,
|
||||
signal_repetitions)
|
||||
new_device.hass = hass
|
||||
RFX_DEVICES[device_id] = new_device
|
||||
devices.append(new_device)
|
||||
return devices
|
||||
|
||||
|
||||
def get_new_device(event, config, device):
|
||||
def get_new_device(event, config, device, hass):
|
||||
"""Add entity if not exist and the automatic_add is True."""
|
||||
device_id = slugify(event.device.id_string.lower())
|
||||
if device_id in RFX_DEVICES:
|
||||
|
@ -235,6 +236,7 @@ def get_new_device(event, config, device):
|
|||
signal_repetitions = config[CONF_SIGNAL_REPETITIONS]
|
||||
new_device = device(pkt_id, event, datas,
|
||||
signal_repetitions)
|
||||
new_device.hass = hass
|
||||
RFX_DEVICES[device_id] = new_device
|
||||
return new_device
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
import RFXtrx as rfxtrxmod
|
||||
|
||||
# Add switch from config file
|
||||
switches = rfxtrx.get_devices_from_config(config, RfxtrxSwitch)
|
||||
switches = rfxtrx.get_devices_from_config(config, RfxtrxSwitch, hass)
|
||||
add_devices_callback(switches)
|
||||
|
||||
def switch_update(event):
|
||||
|
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
event.device.known_to_be_rollershutter:
|
||||
return
|
||||
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxSwitch)
|
||||
new_device = rfxtrx.get_new_device(event, config, RfxtrxSwitch, hass)
|
||||
if new_device:
|
||||
add_devices_callback([new_device])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue