Loading smartir/fan.py +13 −4 Original line number Diff line number Diff line Loading @@ -24,11 +24,13 @@ _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "SmartIR Fan" CONF_UNIQUE_ID = 'unique_id' CONF_DEVICE_CODE = 'device_code' CONF_CONTROLLER_SEND_SERVICE = "controller_send_service" CONF_POWER_SENSOR = 'power_sensor' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_DEVICE_CODE): cv.positive_int, vol.Required(CONF_CONTROLLER_SEND_SERVICE): cv.entity_id, Loading @@ -36,6 +38,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): unique_id = config.get(CONF_UNIQUE_ID) name = config.get(CONF_NAME) device_code = config.get(CONF_DEVICE_CODE) controller_send_service = config.get(CONF_CONTROLLER_SEND_SERVICE) Loading Loading @@ -76,14 +79,15 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return async_add_entities([SmartIRFan( hass, name, device_code, device_data, controller_send_service, power_sensor hass, unique_id, name, device_code, device_data, controller_send_service, power_sensor )]) class SmartIRFan(FanEntity, RestoreEntity): def __init__(self, hass, name, device_code, device_data, controller_send_service, power_sensor): def __init__(self, hass, unique_id, name, device_code, device_data, controller_send_service, power_sensor): self.hass = hass self._unique_id = unique_id self._name = name self._device_code = device_code self._controller_send_service = controller_send_service Loading Loading @@ -134,6 +138,11 @@ class SmartIRFan(FanEntity, RestoreEntity): async_track_state_change(self.hass, self._power_sensor, self._async_power_sensor_changed) @property def unique_id(self): """Return a unique ID.""" return self._unique_id @property def name(self): """Return the display name of the fan.""" Loading Loading
smartir/fan.py +13 −4 Original line number Diff line number Diff line Loading @@ -24,11 +24,13 @@ _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "SmartIR Fan" CONF_UNIQUE_ID = 'unique_id' CONF_DEVICE_CODE = 'device_code' CONF_CONTROLLER_SEND_SERVICE = "controller_send_service" CONF_POWER_SENSOR = 'power_sensor' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_DEVICE_CODE): cv.positive_int, vol.Required(CONF_CONTROLLER_SEND_SERVICE): cv.entity_id, Loading @@ -36,6 +38,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): unique_id = config.get(CONF_UNIQUE_ID) name = config.get(CONF_NAME) device_code = config.get(CONF_DEVICE_CODE) controller_send_service = config.get(CONF_CONTROLLER_SEND_SERVICE) Loading Loading @@ -76,14 +79,15 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return async_add_entities([SmartIRFan( hass, name, device_code, device_data, controller_send_service, power_sensor hass, unique_id, name, device_code, device_data, controller_send_service, power_sensor )]) class SmartIRFan(FanEntity, RestoreEntity): def __init__(self, hass, name, device_code, device_data, controller_send_service, power_sensor): def __init__(self, hass, unique_id, name, device_code, device_data, controller_send_service, power_sensor): self.hass = hass self._unique_id = unique_id self._name = name self._device_code = device_code self._controller_send_service = controller_send_service Loading Loading @@ -134,6 +138,11 @@ class SmartIRFan(FanEntity, RestoreEntity): async_track_state_change(self.hass, self._power_sensor, self._async_power_sensor_changed) @property def unique_id(self): """Return a unique ID.""" return self._unique_id @property def name(self): """Return the display name of the fan.""" Loading