Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ufo-r11 controller #19

Merged
merged 3 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions custom_components/smartir/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
LOOKIN_CONTROLLER = "LOOKin"
ESPHOME_CONTROLLER = "ESPHome"
ZHA_CONTROLLER = "ZHA"
UFOR11_CONTROLLER = "UFOR11"

ENC_BASE64 = "Base64"
ENC_HEX = "Hex"
Expand All @@ -25,6 +26,7 @@
LOOKIN_COMMANDS_ENCODING = [ENC_PRONTO, ENC_RAW]
ESPHOME_COMMANDS_ENCODING = [ENC_RAW]
ZHA_COMMANDS_ENCODING = [ENC_RAW]
UFOR11_COMMANDS_ENCODING = [ENC_RAW]


def get_controller(hass, controller, encoding, controller_data, delay):
Expand All @@ -36,6 +38,7 @@ def get_controller(hass, controller, encoding, controller_data, delay):
LOOKIN_CONTROLLER: LookinController,
ESPHOME_CONTROLLER: ESPHomeController,
ZHA_CONTROLLER: ZHAController,
UFOR11_CONTROLLER: UFOR11Controller,
}
try:
return controllers[controller](
Expand Down Expand Up @@ -213,6 +216,24 @@ async def send(self, command):
)


class UFOR11Controller(MQTTController):
"""Controls a UFO-R11 device."""

def check_encoding(self, encoding):
"""Check if the encoding is supported by the controller."""
if encoding not in UFOR11_COMMANDS_ENCODING:
raise Exception("The encoding is not supported by the UFO-R11 controller.")

async def send(self, command):
"""Send a command."""
service_data = {
"topic": self._controller_data,
"payload": json.dumps({"ir_code_to_send": command}),
}

await self.hass.services.async_call("mqtt", "publish", service_data)


class Helper:
"""Static shared functions."""

Expand Down
2 changes: 1 addition & 1 deletion docs/CLIMATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ climate:
power_sensor: binary_sensor.ac_power
```

## Example (using mqtt controller):
## Example (using mqtt/Z06/UFO-R11 controller):
```yaml
climate:
- platform: smartir
Expand Down
9 changes: 1 addition & 8 deletions docs/FAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fan:
```

## Example (using xiaomi controller)

```yaml
remote:
- platform: xiaomi_miio
Expand All @@ -44,8 +43,7 @@ fan:
power_sensor: binary_sensor.fan_power
```

## Example (using mqtt controller)

## Example (using mqtt/Z06/UFO-R11 controller)
```yaml
fan:
- platform: smartir
Expand All @@ -57,7 +55,6 @@ fan:
```

## Example (using LOOKin controller)

```yaml
fan:
- platform: smartir
Expand All @@ -69,9 +66,7 @@ fan:
```

## Example (using ESPHome)

ESPHome configuration example:

```yaml
esphome:
name: my_espir
Expand All @@ -93,7 +88,6 @@ remote_transmitter:
```

HA configuration.yaml:

```yaml
fan:
- platform: smartir
Expand All @@ -105,7 +99,6 @@ fan:
```

## Example (using ZHA controller and a TuYa ZS06):

```yaml
fan:
- platform: smartir
Expand Down
2 changes: 1 addition & 1 deletion docs/MEDIA_PLAYER.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ media_player:
power_sensor: binary_sensor.tv_power
```

## Example (using mqtt controller):
## Example (using mqtt/Z06/UFO-R11 controller):
```yaml
media_player:
- platform: smartir
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SmartIR currently supports the following controllers:
* [LOOK.in Remote](http://look-in.club/devices/remote)
* [ESPHome User-defined service for remote transmitter](https://esphome.io/components/api.html#user-defined-services)
* [MQTT Publish service](https://www.home-assistant.io/docs/mqtt/service/)
* [Tuya Z06/Moes UFO-R11](https://www.zigbee2mqtt.io/devices/UFO-R11.html)
* [ZHA Zigbee IR remote](https://www.home-assistant.io/integrations/zha/) (May require custom zha quirk for given controller)

More than 120 climate devices are currently supported out-of-the-box, mainly for the Broadlink controller, thanks to our awesome community.
Expand Down
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SmartIR currently supports the following controllers:
* [LOOK.in Remote](http://look-in.club/devices/remote)
* [ESPHome User-defined service for remote transmitter](https://esphome.io/components/api.html#user-defined-services)
* [MQTT Publish service](https://www.home-assistant.io/docs/mqtt/service/)
* [Tuya Z06/Moes UFO-R11](https://www.zigbee2mqtt.io/devices/UFO-R11.html)
* [ZHA Zigbee IR remote](https://www.home-assistant.io/integrations/zha/) (May require custom zha quirk for given controller)

More than 120 climate devices are currently supported out-of-the-box, mainly for the Broadlink controller, thanks to our awesome community.<br>
Expand Down
Loading