diff --git a/homeassistant/components/switch/rpi_rf.py b/homeassistant/components/switch/rpi_rf.py index e646afef172..e48ac1a4d7d 100644 --- a/homeassistant/components/switch/rpi_rf.py +++ b/homeassistant/components/switch/rpi_rf.py @@ -8,8 +8,9 @@ import logging import voluptuous as vol -from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) -from homeassistant.const import (CONF_NAME, CONF_SWITCHES) +from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA +from homeassistant.const import ( + CONF_NAME, CONF_SWITCHES, EVENT_HOMEASSISTANT_STOP) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['rpi-rf==0.9.6'] @@ -71,6 +72,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(devices) + hass.bus.listen_once( + EVENT_HOMEASSISTANT_STOP, lambda event: rfdevice.cleanup()) + class RPiRFSwitch(SwitchDevice): """Representation of a GPIO RF switch."""