Unverified Commit 64bef134 authored by Vassilis Panos's avatar Vassilis Panos Committed by GitHub
Browse files

Merge pull request #337 from smartHomeHub/rc

Rc -> Master
parents b2edb141 63ac2d9a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)

DOMAIN = 'smartir'
VERSION = '1.7.5'
VERSION = '1.8.0'
MANIFEST_URL = (
    "https://raw.githubusercontent.com/"
    "smartHomeHub/SmartIR/{}/"
+21 −8
Original line number Diff line number Diff line
import asyncio
from base64 import b64encode
import binascii
import requests
import logging

from homeassistant.const import ATTR_ENTITY_ID
@@ -12,24 +13,23 @@ _LOGGER = logging.getLogger(__name__)
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 @@ class Controller():
                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
@@ -100,3 +105,11 @@ class Controller():

            await self.hass.services.async_call(
               '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
+2 −2
Original line number Diff line number Diff line
@@ -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",
+15 −0
Original line number Diff line number Diff line
@@ -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.**

+13 −0
Original line number Diff line number Diff line
@@ -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.**

Loading