Loading smartir/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) DOMAIN = 'smartir' VERSION = '1.3.8' VERSION = '1.3.9' VERSION_URL = ( "https://raw.githubusercontent.com/" "smartHomeHub/SmartIR/{}/version.json") Loading smartir/climate.py +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_TEMPERATURE_SENSOR): cv.entity_id, vol.Optional(CONF_HUMIDITY_SENSOR): cv.entity_id, vol.Optional(CONF_POWER_SENSOR): cv.entity_id Loading Loading @@ -132,7 +132,7 @@ class SmartIRClimate(ClimateDevice, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading smartir/controller.py +50 −40 Original line number Diff line number Diff line Loading @@ -18,20 +18,31 @@ ENC_RAW = 'Raw' BROADLINK_COMMANDS_ENCODING = [ ENC_BASE64, ENC_HEX, ENC_PRONTO] MQTT_COMMANDS_ENCODING = [ENC_RAW] class Controller(): def __init__(self, hass, controller, encoding, service, topic): def __init__(self, hass, controller, encoding, service, topic=None): if controller not in [ BROADLINK_CONTROLLER, MQTT_CONTROLLER, XIAOMI_CONTROLLER]: BROADLINK_CONTROLLER, XIAOMI_CONTROLLER, MQTT_CONTROLLER]: raise Exception("The controller is not supported.") if controller == BROADLINK_CONTROLLER: if encoding not in BROADLINK_COMMANDS_ENCODING: raise Exception("The encoding is not supported " "by the Broadlink controller.") if controller == XIAOMI_CONTROLLER: raise Exception("The Xiaomi IR controller " "is not yet supported.") if controller == BROADLINK_CONTROLLER: if encoding not in BROADLINK_COMMANDS_ENCODING: if controller == MQTT_CONTROLLER: if encoding not in MQTT_COMMANDS_ENCODING: raise Exception("The encoding is not supported " "by the Broadlink controller.") "by the mqtt controller.") if not topic: raise Exception("controller_command_topic must be " "specified for mqtt controllers.") self.hass = hass self._service_domain = split_entity_id(service)[0] Loading @@ -40,15 +51,8 @@ class Controller(): self._controller = controller self._encoding = encoding if self._service_domain == 'mqtt': if self._command_topic == '': raise Exception("controller_command_topic must be " "specified for mqtt controllers.") async def send(self, command): if self._controller not in [BROADLINK_CONTROLLER, MQTT_CONTROLLER]: raise Exception("Unsupported controller") if self._controller == BROADLINK_CONTROLLER: if self._encoding == ENC_HEX: try: command = binascii.unhexlify(command) Loading @@ -68,10 +72,16 @@ class Controller(): raise Exception("Error while converting " "Pronto to Base64 encoding") if self._controller == BROADLINK_CONTROLLER: service_data = {'packet': command} service_data = { 'packet': command } await self.hass.services.async_call( self._service_domain, self._service_name, service_data) if self._controller = MQTT_CONTROLLER: if self._controller == MQTT_CONTROLLER: service_data = { 'topic': self._command_topic, 'payload': command Loading smartir/fan.py +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) Loading Loading @@ -115,7 +115,7 @@ class SmartIRFan(FanEntity, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading smartir/media_player.py +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) Loading Loading @@ -133,7 +133,7 @@ class SmartIRMediaPlayer(MediaPlayerDevice, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading Loading
smartir/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) DOMAIN = 'smartir' VERSION = '1.3.8' VERSION = '1.3.9' VERSION_URL = ( "https://raw.githubusercontent.com/" "smartHomeHub/SmartIR/{}/version.json") Loading
smartir/climate.py +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_TEMPERATURE_SENSOR): cv.entity_id, vol.Optional(CONF_HUMIDITY_SENSOR): cv.entity_id, vol.Optional(CONF_POWER_SENSOR): cv.entity_id Loading Loading @@ -132,7 +132,7 @@ class SmartIRClimate(ClimateDevice, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading
smartir/controller.py +50 −40 Original line number Diff line number Diff line Loading @@ -18,20 +18,31 @@ ENC_RAW = 'Raw' BROADLINK_COMMANDS_ENCODING = [ ENC_BASE64, ENC_HEX, ENC_PRONTO] MQTT_COMMANDS_ENCODING = [ENC_RAW] class Controller(): def __init__(self, hass, controller, encoding, service, topic): def __init__(self, hass, controller, encoding, service, topic=None): if controller not in [ BROADLINK_CONTROLLER, MQTT_CONTROLLER, XIAOMI_CONTROLLER]: BROADLINK_CONTROLLER, XIAOMI_CONTROLLER, MQTT_CONTROLLER]: raise Exception("The controller is not supported.") if controller == BROADLINK_CONTROLLER: if encoding not in BROADLINK_COMMANDS_ENCODING: raise Exception("The encoding is not supported " "by the Broadlink controller.") if controller == XIAOMI_CONTROLLER: raise Exception("The Xiaomi IR controller " "is not yet supported.") if controller == BROADLINK_CONTROLLER: if encoding not in BROADLINK_COMMANDS_ENCODING: if controller == MQTT_CONTROLLER: if encoding not in MQTT_COMMANDS_ENCODING: raise Exception("The encoding is not supported " "by the Broadlink controller.") "by the mqtt controller.") if not topic: raise Exception("controller_command_topic must be " "specified for mqtt controllers.") self.hass = hass self._service_domain = split_entity_id(service)[0] Loading @@ -40,15 +51,8 @@ class Controller(): self._controller = controller self._encoding = encoding if self._service_domain == 'mqtt': if self._command_topic == '': raise Exception("controller_command_topic must be " "specified for mqtt controllers.") async def send(self, command): if self._controller not in [BROADLINK_CONTROLLER, MQTT_CONTROLLER]: raise Exception("Unsupported controller") if self._controller == BROADLINK_CONTROLLER: if self._encoding == ENC_HEX: try: command = binascii.unhexlify(command) Loading @@ -68,10 +72,16 @@ class Controller(): raise Exception("Error while converting " "Pronto to Base64 encoding") if self._controller == BROADLINK_CONTROLLER: service_data = {'packet': command} service_data = { 'packet': command } await self.hass.services.async_call( self._service_domain, self._service_name, service_data) if self._controller = MQTT_CONTROLLER: if self._controller == MQTT_CONTROLLER: service_data = { 'topic': self._command_topic, 'payload': command Loading
smartir/fan.py +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) Loading Loading @@ -115,7 +115,7 @@ class SmartIRFan(FanEntity, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading
smartir/media_player.py +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ 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, vol.Required(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) Loading Loading @@ -133,7 +133,7 @@ class SmartIRMediaPlayer(MediaPlayerDevice, RestoreEntity): self.hass, self._supported_controller, self._commands_encoding, self._controller_send_service self._controller_send_service, self._controller_command_topic) async def async_added_to_hass(self): Loading