diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index 30a670a6a27..27d931106c4 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -39,7 +39,9 @@ DATA_TYPES = OrderedDict([ ('Wind direction', ''), ('Rain rate', ''), ('Energy usage', 'W'), - ('Total usage', 'W')]) + ('Total usage', 'W'), + ('Sensor Status', ''), + ('Unknown', '')]) RECEIVED_EVT_SUBSCRIBERS = [] RFX_DEVICES = {} diff --git a/homeassistant/components/sensor/rfxtrx.py b/homeassistant/components/sensor/rfxtrx.py index 196b0bfbbd1..49912acb621 100644 --- a/homeassistant/components/sensor/rfxtrx.py +++ b/homeassistant/components/sensor/rfxtrx.py @@ -75,10 +75,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): _LOGGER.info("Automatic add rfxtrx.sensor: %s", device_id) - for data_type in DATA_TYPES: - if data_type in event.values: - new_sensor = RfxtrxSensor(event, pkt_id, data_type) + data_type = "Unknown" + for _data_type in DATA_TYPES: + if _data_type in event.values: + data_type = _data_type break + new_sensor = RfxtrxSensor(event, pkt_id, data_type) sub_sensors = {} sub_sensors[new_sensor.data_type] = new_sensor rfxtrx.RFX_DEVICES[device_id] = sub_sensors @@ -94,12 +96,11 @@ class RfxtrxSensor(Entity): def __init__(self, event, name, data_type): """Initialize the sensor.""" self.event = event - self._unit_of_measurement = None - self.data_type = None self._name = name - if data_type: - self.data_type = data_type - self._unit_of_measurement = DATA_TYPES[data_type] + if data_type not in DATA_TYPES: + data_type = "Unknown" + self.data_type = data_type + self._unit_of_measurement = DATA_TYPES[data_type] def __str__(self): """Return the name of the sensor."""