mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
updated rfxcom sensor
This commit is contained in:
parent
1489af0eca
commit
3658c57912
@ -25,36 +25,26 @@ REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/master.zip'
|
|||||||
DATA_TYPES = OrderedDict([
|
DATA_TYPES = OrderedDict([
|
||||||
('Temperature', TEMP_CELCIUS),
|
('Temperature', TEMP_CELCIUS),
|
||||||
('Humidity', '%'),
|
('Humidity', '%'),
|
||||||
('Forecast', ''),
|
|
||||||
('Barometer', ''),
|
('Barometer', ''),
|
||||||
('Wind direction', ''),
|
('Wind direction', ''),
|
||||||
('Humidity status', ''),
|
('Rain rate', '')])
|
||||||
('Humidity status numeric', ''),
|
|
||||||
('Forecast numeric', ''),
|
|
||||||
('Rain rate', ''),
|
|
||||||
('Rain total', ''),
|
|
||||||
('Wind average speed', ''),
|
|
||||||
('Wind gust', ''),
|
|
||||||
('Chill', ''),
|
|
||||||
('Battery numeric', '%'),
|
|
||||||
('Rssi numeric', '')])
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Setup the rfxtrx platform. """
|
""" Setup the rfxtrx platform. """
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
devices = {} # keep track of devices added to HA
|
sensors = {} # keep track of sensors added to HA
|
||||||
|
|
||||||
def sensor_update(event):
|
def sensor_update(event):
|
||||||
""" Callback for sensor updates from the MySensors gateway. """
|
""" Callback for sensor updates from the RFXtrx gateway. """
|
||||||
if event.device.id_string in devices:
|
if event.device.id_string in sensors:
|
||||||
devices[event.device.id_string].event = event
|
sensors[event.device.id_string].event = event
|
||||||
else:
|
else:
|
||||||
logger.info("adding new devices: %s", event.device.type_string)
|
logger.info("adding new sensor: %s", event.device.type_string)
|
||||||
new_device = RfxtrxSensor(event)
|
new_sensor = RfxtrxSensor(event)
|
||||||
devices[event.device.id_string] = new_device
|
sensors[event.device.id_string] = new_sensor
|
||||||
add_devices([new_device])
|
add_devices([new_sensor])
|
||||||
try:
|
try:
|
||||||
import RFXtrx as rfxtrx
|
import RFXtrx as rfxtrx
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -62,12 +52,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"Failed to import rfxtrx")
|
"Failed to import rfxtrx")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
device = config.get("device", True)
|
device = config.get("device", "")
|
||||||
rfxtrx.Core(device, sensor_update)
|
rfxtrx.Core(device, sensor_update)
|
||||||
|
|
||||||
|
|
||||||
class RfxtrxSensor(Entity):
|
class RfxtrxSensor(Entity):
|
||||||
""" Represents a Vera Sensor. """
|
""" Represents a Rfxtrx Sensor. """
|
||||||
|
|
||||||
def __init__(self, event):
|
def __init__(self, event):
|
||||||
self.event = event
|
self.event = event
|
||||||
|
Loading…
x
Reference in New Issue
Block a user