diff --git a/custom_components/smartir/__init__.py b/custom_components/smartir/__init__.py index a0df8207..b9eb7508 100644 --- a/custom_components/smartir/__init__.py +++ b/custom_components/smartir/__init__.py @@ -19,7 +19,7 @@ _LOGGER = logging.getLogger(__name__) DOMAIN = 'smartir' -VERSION = '1.7.5' +VERSION = '1.8.0' MANIFEST_URL = ( "https://raw.githubusercontent.com/" "smartHomeHub/SmartIR/{}/" diff --git a/custom_components/smartir/controller.py b/custom_components/smartir/controller.py index 993c549b..c368a8b0 100644 --- a/custom_components/smartir/controller.py +++ b/custom_components/smartir/controller.py @@ -1,6 +1,7 @@ import asyncio from base64 import b64encode import binascii +import requests import logging from homeassistant.const import ATTR_ENTITY_ID @@ -12,24 +13,23 @@ BROADLINK_CONTROLLER = 'Broadlink' XIAOMI_CONTROLLER = 'Xiaomi' MQTT_CONTROLLER = 'MQTT' +LOOKIN_CONTROLLER = 'LOOKin' ENC_BASE64 = 'Base64' ENC_HEX = 'Hex' ENC_PRONTO = 'Pronto' ENC_RAW = 'Raw' -BROADLINK_COMMANDS_ENCODING = [ - ENC_BASE64, ENC_HEX, ENC_PRONTO] - -XIAOMI_COMMANDS_ENCODING = [ - ENC_PRONTO, ENC_RAW] - +BROADLINK_COMMANDS_ENCODING = [ENC_BASE64, ENC_HEX, ENC_PRONTO] +XIAOMI_COMMANDS_ENCODING = [ENC_PRONTO, ENC_RAW] MQTT_COMMANDS_ENCODING = [ENC_RAW] +LOOKIN_COMMANDS_ENCODING = [ENC_PRONTO, ENC_RAW] class Controller(): def __init__(self, hass, controller, encoding, controller_data): if controller not in [ - BROADLINK_CONTROLLER, XIAOMI_CONTROLLER, MQTT_CONTROLLER]: + BROADLINK_CONTROLLER, XIAOMI_CONTROLLER, + MQTT_CONTROLLER, LOOKIN_CONTROLLER]: raise Exception("The controller is not supported.") if controller == BROADLINK_CONTROLLER: @@ -47,6 +47,11 @@ def __init__(self, hass, controller, encoding, controller_data): raise Exception("The encoding is not supported " "by the mqtt controller.") + if controller == LOOKIN_CONTROLLER: + if encoding not in LOOKIN_COMMANDS_ENCODING: + raise Exception("The encoding is not supported " + "by the LOOKin controller.") + self.hass = hass self._controller = controller self._encoding = encoding @@ -99,4 +104,12 @@ async def send(self, command): } await self.hass.services.async_call( - 'mqtt', 'publish', service_data) \ No newline at end of file + 'mqtt', 'publish', service_data) + + if self._controller == LOOKIN_CONTROLLER: + encoding = self._encoding.lower().replace('pronto', 'prontohex') + url = f"http://{self._controller_data}/commands/ir/" \ + f"{encoding}/{command}" + await self.hass.async_add_executor_job( + requests.get, url + ) \ No newline at end of file diff --git a/custom_components/smartir/manifest.json b/custom_components/smartir/manifest.json index ca0b2597..0b48ceb4 100644 --- a/custom_components/smartir/manifest.json +++ b/custom_components/smartir/manifest.json @@ -7,8 +7,8 @@ "requirements": ["aiofiles==0.5.0"], "homeassistant": "0.96.0", "updater": { - "version": "1.7.5", - "releaseNotes": "-- Fix doing I/O", + "version": "1.8.0", + "releaseNotes": "-- Adds support for LOOKin IR controller", "files": [ "__init__.py", "climate.py", diff --git a/docs/CLIMATE.md b/docs/CLIMATE.md index 4ffafcf4..62496e36 100644 --- a/docs/CLIMATE.md +++ b/docs/CLIMATE.md @@ -70,6 +70,21 @@ climate: power_sensor: binary_sensor.ac_power ``` +## Example (using LOOKin controller): +```yaml +smartir: + +climate: + - platform: smartir + name: Office AC + unique_id: office_ac + device_code: 4000 + controller_data: 192.168.10.10 + temperature_sensor: sensor.temperature + humidity_sensor: sensor.humidity + power_sensor: binary_sensor.ac_power +``` + ## Available codes for climate devices: Below are the code files created by the people in the community. Before you start creating your own code file, try if one of them works for your device. **Please open an issue if your device is working and not included in the supported models.** diff --git a/docs/FAN.md b/docs/FAN.md index 9a0d9926..824e94ac 100644 --- a/docs/FAN.md +++ b/docs/FAN.md @@ -60,6 +60,19 @@ fan: power_sensor: binary_sensor.fan_power ``` +## Example (using LOOKin controller): +```yaml +smartir: + +fan: + - platform: smartir + name: Bedroom fan + unique_id: bedroom_fan + device_code: 4000 + controller_data: 192.168.10.10 + power_sensor: binary_sensor.fan_power +``` + ## Available codes for Fan devices: Below are the code files created by the people in the community. Before you start creating your own code file, try if one of them works for your device. **Please open an issue if your device is working and not included in the supported models.** diff --git a/docs/MEDIA_PLAYER.md b/docs/MEDIA_PLAYER.md index 292ded31..4bc0cf87 100644 --- a/docs/MEDIA_PLAYER.md +++ b/docs/MEDIA_PLAYER.md @@ -62,6 +62,19 @@ media_player: power_sensor: binary_sensor.tv_power ``` +## Example (using LOOKin controller): +```yaml +smartir: + +media_player: + - platform: smartir + name: Living room TV + unique_id: living_room_tv + device_code: 4000 + controller_data: 192.168.10.10 + power_sensor: binary_sensor.tv_power +``` + ### Overriding Source Names Source names in device files are usually set to the name that the media player uses. These often aren't very descriptive, so you can override these names in the configuration file. You can also remove a source by setting its name to `null` diff --git a/docs/README.md b/docs/README.md index 8b4f7171..5c57dda5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,5 @@ +[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg)](https://github.com/custom-components/hacs) + SmartIR is a custom [Home Assistant](https://www.home-assistant.io/) component for controlling AC units, TV sets and fans via Infrared and RF controllers. An IR or RF controller such as Broadlink is required. The key features of the component are: @@ -6,6 +8,13 @@ The key features of the component are: * Support for external on/off sensor that monitors whether your device is actually On or Off. This may be a power monitor sensor. * Support for voice assistants. + +## **Supported controllers** +* [Broadlink](https://www.home-assistant.io/integrations/broadlink/) +* [Xiaomi IR Remote (ChuangmiIr)](https://www.home-assistant.io/integrations/remote.xiaomi_miio/) +* [LOOK.in Remote](http://look-in.club/devices/remote) +* [MQTT Publish service](https://www.home-assistant.io/docs/mqtt/service/) + ## **Component setup instructions** 1. Create a directory `custom_components` in your Home Assistant configuration directory. 2. Copy `smartir` from this project including **all** files and sub-directories into the directory `custom_components`. @@ -53,4 +62,4 @@ smartir: * [Discussion about SmartIR Climate (Home Assistant Community)](https://community.home-assistant.io/t/smartir-control-your-climate-tv-and-fan-devices-via-ir-rf-controllers/) ### Give this Project a Star :star: -Star this repository if you had fun! \ No newline at end of file +Star this repository if you had fun! diff --git a/info.md b/info.md index 56adca2b..b12cc447 100644 --- a/info.md +++ b/info.md @@ -2,6 +2,12 @@ SmartIR is a custom integration for controlling AC units, TV sets and fans via Infrared and RF controllers. An IR or RF controller such as Broadlink is required. +## **Supported controllers** +* [Broadlink](https://www.home-assistant.io/integrations/broadlink/) +* [Xiaomi IR Remote (ChuangmiIr)](https://www.home-assistant.io/integrations/remote.xiaomi_miio/) +* [LOOK.in Remote](http://look-in.club/devices/remote) +* [MQTT Publish service](https://www.home-assistant.io/docs/mqtt/service/) + ## **Platform setup instructions**

SmartIR Climate @@ -14,3 +20,6 @@ SmartIR is a custom integration for controlling AC units, TV sets and fans via I

SmartIR Media Player

+ +### Give this Project a Star :star: +Star this repository if you had fun!