diff --git a/homeassistant/components/binary_sensor/insteon_plm.py b/homeassistant/components/binary_sensor/insteon_plm.py index 9cb87b31749..25fc3fb5d73 100644 --- a/homeassistant/components/binary_sensor/insteon_plm.py +++ b/homeassistant/components/binary_sensor/insteon_plm.py @@ -17,7 +17,9 @@ _LOGGER = logging.getLogger(__name__) SENSOR_TYPES = {'openClosedSensor': 'opening', 'motionSensor': 'motion', 'doorSensor': 'door', - 'wetLeakSensor': 'moisture'} + 'wetLeakSensor': 'moisture', + 'lightSensor': 'light', + 'batterySensor': 'battery'} @asyncio.coroutine @@ -54,4 +56,9 @@ class InsteonPLMBinarySensor(InsteonPLMEntity, BinarySensorDevice): @property def is_on(self): """Return the boolean response if the node is on.""" - return bool(self._insteon_device_state.value) + on_val = bool(self._insteon_device_state.value) + + if self._insteon_device_state.name == 'lightSensor': + return not on_val + + return on_val diff --git a/homeassistant/components/insteon_plm/__init__.py b/homeassistant/components/insteon_plm/__init__.py index 82fc6b02266..ef631223894 100644 --- a/homeassistant/components/insteon_plm/__init__.py +++ b/homeassistant/components/insteon_plm/__init__.py @@ -17,7 +17,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['insteonplm==0.11.3'] +REQUIREMENTS = ['insteonplm==0.11.7'] _LOGGER = logging.getLogger(__name__) @@ -55,6 +55,11 @@ SRV_HOUSECODE = 'housecode' HOUSECODES = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'] +BUTTON_PRESSED_STATE_NAME = 'onLevelButton' +EVENT_BUTTON_ON = 'insteon_plm.button_on' +EVENT_BUTTON_OFF = 'insteon_plm.button_off' +EVENT_CONF_BUTTON = 'button' + CONF_DEVICE_OVERRIDE_SCHEMA = vol.All( cv.deprecated(CONF_PLATFORM), vol.Schema({ vol.Required(CONF_ADDRESS): cv.string, @@ -130,9 +135,14 @@ def async_setup(hass, config): """Detect device from transport to be delegated to platform.""" for state_key in device.states: platform_info = ipdb[device.states[state_key]] - if platform_info: + if platform_info and platform_info.platform: platform = platform_info.platform - if platform: + + if platform == 'on_off_events': + device.states[state_key].register_updates( + _fire_button_on_off_event) + + else: _LOGGER.info("New INSTEON PLM device: %s (%s) %s", device.address, device.states[state_key].name, @@ -223,6 +233,23 @@ def async_setup(hass, config): schema=X10_HOUSECODE_SCHEMA) _LOGGER.debug("Insteon_plm Services registered") + def _fire_button_on_off_event(address, group, val): + # Firing an event when a button is pressed. + device = plm.devices[address.hex] + state_name = device.states[group].name + button = ("" if state_name == BUTTON_PRESSED_STATE_NAME + else state_name[-1].lower()) + schema = {CONF_ADDRESS: address.hex} + if button != "": + schema[EVENT_CONF_BUTTON] = button + if val: + event = EVENT_BUTTON_ON + else: + event = EVENT_BUTTON_OFF + _LOGGER.debug('Firing event %s with address %s and button %s', + event, address.hex, button) + hass.bus.fire(event, schema) + _LOGGER.info("Looking for PLM on %s", port) conn = yield from insteonplm.Connection.create( device=port, @@ -329,7 +356,7 @@ class IPDB(object): State(DimmableSwitch_Fan, 'fan'), State(DimmableSwitch, 'light'), - State(DimmableRemote, 'binary_sensor'), + State(DimmableRemote, 'on_off_events'), State(X10DimmableSwitch, 'light'), State(X10OnOffSwitch, 'switch'), diff --git a/requirements_all.txt b/requirements_all.txt index 8ef15e4bd18..1ef32386148 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -452,7 +452,7 @@ influxdb==5.0.0 insteonlocal==0.53 # homeassistant.components.insteon_plm -insteonplm==0.11.3 +insteonplm==0.11.7 # homeassistant.components.sensor.iperf3 iperf3==0.1.10