Skip to content

Commit

Permalink
Merge pull request smartHomeHub#337 from smartHomeHub/rc
Browse files Browse the repository at this point in the history
Rc -> Master
  • Loading branch information
vassilis-panos authored May 5, 2020
2 parents b2edb14 + 63ac2d9 commit 64bef13
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 12 deletions.
2 changes: 1 addition & 1 deletion custom_components/smartir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/{}/"
Expand Down
29 changes: 21 additions & 8 deletions custom_components/smartir/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
from base64 import b64encode
import binascii
import requests
import logging

from homeassistant.const import ATTR_ENTITY_ID
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -99,4 +104,12 @@ async def send(self, command):
}

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
)
4 changes: 2 additions & 2 deletions custom_components/smartir/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions docs/CLIMATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
13 changes: 13 additions & 0 deletions docs/FAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
13 changes: 13 additions & 0 deletions docs/MEDIA_PLAYER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
11 changes: 10 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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`.
Expand Down Expand Up @@ -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!
Star this repository if you had fun!
9 changes: 9 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
<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>
Expand All @@ -14,3 +20,6 @@ SmartIR is a custom integration for controlling AC units, TV sets and fans via I
<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>
</p>

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

0 comments on commit 64bef13

Please sign in to comment.