Kaynağa Gözat

Merge pull request #337 from smartHomeHub/rc

Rc -> Master
Vassilis Panos 6 yıl önce
ebeveyn
işleme
64bef13445

+ 1 - 1
custom_components/smartir/__init__.py

@@ -19,7 +19,7 @@ from homeassistant.helpers.typing import ConfigType
 _LOGGER = logging.getLogger(__name__)
 _LOGGER = logging.getLogger(__name__)
 
 
 DOMAIN = 'smartir'
 DOMAIN = 'smartir'
-VERSION = '1.7.5'
+VERSION = '1.8.0'
 MANIFEST_URL = (
 MANIFEST_URL = (
     "https://raw.githubusercontent.com/"
     "https://raw.githubusercontent.com/"
     "smartHomeHub/SmartIR/{}/"
     "smartHomeHub/SmartIR/{}/"

+ 21 - 8
custom_components/smartir/controller.py

@@ -1,6 +1,7 @@
 import asyncio
 import asyncio
 from base64 import b64encode
 from base64 import b64encode
 import binascii
 import binascii
+import requests
 import logging
 import logging
 
 
 from homeassistant.const import ATTR_ENTITY_ID
 from homeassistant.const import ATTR_ENTITY_ID
@@ -12,24 +13,23 @@ _LOGGER = logging.getLogger(__name__)
 BROADLINK_CONTROLLER = 'Broadlink'
 BROADLINK_CONTROLLER = 'Broadlink'
 XIAOMI_CONTROLLER = 'Xiaomi'
 XIAOMI_CONTROLLER = 'Xiaomi'
 MQTT_CONTROLLER = 'MQTT'
 MQTT_CONTROLLER = 'MQTT'
+LOOKIN_CONTROLLER = 'LOOKin'
 
 
 ENC_BASE64 = 'Base64'
 ENC_BASE64 = 'Base64'
 ENC_HEX = 'Hex'
 ENC_HEX = 'Hex'
 ENC_PRONTO = 'Pronto'
 ENC_PRONTO = 'Pronto'
 ENC_RAW = 'Raw'
 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]
 MQTT_COMMANDS_ENCODING = [ENC_RAW]
+LOOKIN_COMMANDS_ENCODING = [ENC_PRONTO, ENC_RAW]
 
 
 class Controller():
 class Controller():
     def __init__(self, hass, controller, encoding, controller_data):
     def __init__(self, hass, controller, encoding, controller_data):
         if controller not in [
         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.")
             raise Exception("The controller is not supported.")
 
 
         if controller == BROADLINK_CONTROLLER:
         if controller == BROADLINK_CONTROLLER:
@@ -47,6 +47,11 @@ class Controller():
                 raise Exception("The encoding is not supported "
                 raise Exception("The encoding is not supported "
                                 "by the mqtt controller.")
                                 "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.hass = hass
         self._controller = controller
         self._controller = controller
         self._encoding = encoding
         self._encoding = encoding
@@ -99,4 +104,12 @@ class Controller():
             }
             }
 
 
             await self.hass.services.async_call(
             await self.hass.services.async_call(
-               'mqtt', 'publish', service_data)
+               '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
+            )

+ 2 - 2
custom_components/smartir/manifest.json

@@ -7,8 +7,8 @@
   "requirements": ["aiofiles==0.5.0"],
   "requirements": ["aiofiles==0.5.0"],
   "homeassistant": "0.96.0",
   "homeassistant": "0.96.0",
   "updater": {
   "updater": {
-    "version": "1.7.5",
-    "releaseNotes": "-- Fix doing I/O",
+    "version": "1.8.0",
+    "releaseNotes": "-- Adds support for LOOKin IR controller",
     "files": [
     "files": [
       "__init__.py",
       "__init__.py",
       "climate.py",
       "climate.py",

+ 15 - 0
docs/CLIMATE.md

@@ -70,6 +70,21 @@ climate:
     power_sensor: binary_sensor.ac_power
     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:
 ## 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.**
 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.**
 
 

+ 13 - 0
docs/FAN.md

@@ -60,6 +60,19 @@ fan:
     power_sensor: binary_sensor.fan_power
     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:
 ## 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.**
 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.**
 
 

+ 13 - 0
docs/MEDIA_PLAYER.md

@@ -62,6 +62,19 @@ media_player:
     power_sensor: binary_sensor.tv_power
     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
 ### 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`
 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`
 
 

+ 10 - 1
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.
 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:
 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 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.
 * 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**
 ## **Component setup instructions**
 1. Create a directory `custom_components` in your Home Assistant configuration directory.
 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`.
 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/)
 * [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:
 ### Give this Project a Star :star:
-Star this repository if you had fun!
+Star this repository if you had fun!

+ 9 - 0
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.
 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**
 ## **Platform setup instructions**
 <p align="center">
 <p align="center">
   <a href="https://github.com/smartHomeHub/SmartIR/blob/master/docs/CLIMATE.md"><img src="https://raw.githubusercontent.com/smartHomeHub/SmartIR/master/docs/assets/smartir_climate.png" width="400" alt="SmartIR Climate"></a>
   <a href="https://github.com/smartHomeHub/SmartIR/blob/master/docs/CLIMATE.md"><img src="https://raw.githubusercontent.com/smartHomeHub/SmartIR/master/docs/assets/smartir_climate.png" width="400" alt="SmartIR Climate"></a>
@@ -14,3 +20,6 @@ SmartIR is a custom integration for controlling AC units, TV sets and fans via I
 <p align="center">
 <p align="center">
   <a href="https://github.com/smartHomeHub/SmartIR/blob/master/docs/FAN.md"><img src="https://raw.githubusercontent.com/smartHomeHub/SmartIR/master/docs/assets/smartir_fan.png" width="400" alt="SmartIR Media Player"></a>
   <a href="https://github.com/smartHomeHub/SmartIR/blob/master/docs/FAN.md"><img src="https://raw.githubusercontent.com/smartHomeHub/SmartIR/master/docs/assets/smartir_fan.png" width="400" alt="SmartIR Media Player"></a>
 </p>
 </p>
+
+### Give this Project a Star :star:
+Star this repository if you had fun!