Commit a22a46d1 authored by Vassilis Panos's avatar Vassilis Panos
Browse files

Initial support for Xiaomi controller

parent 655baa17
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)

DOMAIN = 'smartir'
VERSION = '1.4.2'
VERSION = '1.5.0'
VERSION_URL = (
    "https://raw.githubusercontent.com/"
    "smartHomeHub/SmartIR/{}/version.json")
+22 −5
Original line number Diff line number Diff line
@@ -3,12 +3,15 @@ from base64 import b64encode
import binascii
import logging

from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import split_entity_id
from . import Helper

_LOGGER = logging.getLogger(__name__)

BROADLINK_CONTROLLER = 'Broadlink'
MQTT_CONTROLLER = 'MQTT'
XIAOMI_CONTROLLER = 'Xiaomi'
MQTT_CONTROLLER = 'MQTT'

ENC_BASE64 = 'Base64'
ENC_HEX = 'Hex'
@@ -18,6 +21,9 @@ ENC_RAW = 'Raw'
BROADLINK_COMMANDS_ENCODING = [
    ENC_BASE64, ENC_HEX, ENC_PRONTO]

XIAOMI_COMMANDS_ENCODING = [
    ENC_PRONTO, ENC_RAW]

MQTT_COMMANDS_ENCODING = [ENC_RAW]

class Controller():
@@ -32,8 +38,9 @@ class Controller():
                                "by the Broadlink controller.")

        if controller == XIAOMI_CONTROLLER:
            raise Exception("The Xiaomi IR controller "
                            "is not yet supported.")
            if encoding not in XIAOMI_COMMANDS_ENCODING:
                raise Exception("The encoding is not supported "
                                "by the Xiaomi controller.")

        if controller == MQTT_CONTROLLER:
            if encoding not in MQTT_COMMANDS_ENCODING:
@@ -75,6 +82,16 @@ class Controller():
                'broadlink', 'send', service_data)


        if self._controller == XIAOMI_CONTROLLER:
            service_data = {
                ATTR_ENTITY_ID: self._controller_data,
                'command':  self._encoding.lower() + ':' + command
            }

            await self.hass.services.async_call(
               'remote', 'send_command', service_data)


        if self._controller == MQTT_CONTROLLER:
            service_data = {
                'topic': self._controller_data,
+2 −2
Original line number Diff line number Diff line
{            
    "version": "1.4.2",
    "version": "1.5.0",
    "minHAVersion": "0.92.0b0",
    "releaseNotes": "A new version (1.4.2) is available that is compatible with your system. **This version has a breaking change in the configuration!** Call the ``smartir.update_component`` service to update the component.",
    "releaseNotes": "A new version (1.5.0) is available that is compatible with your system. Call the ``smartir.update_component`` service to update the component.",
    "files": [
        "__init__.py",
        "climate.py",