Broadlink IR Climate Component


#491

So here we go with my cards again and also the code for it:

Be aware I am using using the following:
-Lights: Broadlink TC2 switch (RF switches, no neutral wire required). Managed by Broadlink IR component.
-Fan: Broadlink TC2 switch (RF switch, no neutral wire required), just turn on and off from the switch itself because if I go the IR route to control the fan/speed and if the switch is off, obviously it won’t turn on. (Managed by Broadlink IR component).


-AC: Broadlink IR component switch IR codes to turn on and off. The AC is a wall split AC, it is the dumbest AC you could probably get, so it has the same IR code to turn on/off and then different IR codes for every thermostat/mode combination. I solved this by putting a door sensor which updates instantly whether the AC is on or off, so far it’s 100% accurate, my automations to turn it on and off automatically based on motion/home presence are great.
-AC thermostat: well obviously the component of this thread, just passing the IR codes for the thermostat/mode. No turn on or off here.


-Lumen/Lux sensor: Xiaomi Aqara Motion sensor which has motion, lumen, lux.

-Temperature sensor: Xiaomi bluetooth temperature LCD sensor which gives me temperature and humidity readings (for the living room), for the bedroom I am using the Broadlink IR integrated temperature sensor. There’s also very small ones without the screen which provide extra additional readings (barometers or who knows what).


-The lamps are the Xiaomi Gateway in my Living Room which only turns itself at night when it’s dark (because it has an illumination sensor) and while there’s movement. For my bedroom it is a standing lamp, which is controlled by a TP-Link plug.

For the media players, it’s a Xiaomi Mi Box and some Google Home minis, I use the Chromecast control integration. I use this custom card:

Also you will require this card for the vertical stack-in card:

I probably went for the cheapest stuff and it works great along with a Raspberry Pi 3B+ with tons of stuff running on it.
Almost every single item is less than 25 bucks.
Broadlink TC2 switches(2 and 3 gangs): ~25 USD
Xiaomi Bluetooth temperature sensor: ~12 USD
Door sensors: ~8 USD
Xiaomi Aqara Motion Sensor: ~12 USD
Dlink smart plug: ~10USD
Broadlink IR remote: ~25USD

Inconvenience is that since I’ve got a dumb ACs and I am renting then I need multiple Broadlink IR remotes but I can also load balance them so each one controls the lights (RF) of the room they’re in instead of giving all the work to a single Broadlink IR remote.
I am a renter so no hardcore stuff, just replacing the light switches which is pretty easy.
Lovelace UI YAML

  - type: vertical-stack
    cards:
      - type: custom:vertical-stack-in-card
        title: Bedroom
        cards:
          - type: glance
            title: Lights
            entities:
                - entity: switch.bedroomlight
                  tap_action: toggle
                  hold_action: more-info
                - entity: switch.bedroomlamp
                  tap_action: toggle
                  hold_action: more-info
          - type: glance
            title: Climate Control
            entities:
                - entity: switch.bedroomfan
                  tap_action: toggle
                  hold_action: more-info
                - entity: input_boolean.fanautobr
                  tap_action: toggle
                  hold_action: more-info
                  name: 'Auto'
                - entity: switch.bedroomairconditioner
                  tap_action: toggle
                  hold_action: more-info
                - entity: input_boolean.acautobr
                  tap_action: toggle
                  hold_action: more-info
                  name: 'Auto'
          - type: thermostat
            entity: climate.bedroom_air_conditioner
          - type: glance
            entities:
                - sensor.illumination_158d0001e5cc4e
                - sensor.broadlink_sensor_temperature
          - type: custom:mini-media-player
            entity: media_player.bedroom_speaker_3_2
            artwork: cover
            show_source: true
            show_progress: true
            show_shuffle: true

          - type: glance
            title: Lights
            entities:
                - entity: switch.couchlight
                  tap_action: toggle
                  hold_action: more-info
                - entity: switch.tablelight
                  tap_action: toggle
                  hold_action: more-info
                - entity: switch.kitchenlight
                  tap_action: toggle
                  hold_action: more-info
                - entity: light.gateway_light_7811dcdef518
                  tap_action: toggle
                  hold_action: more-info
                  name: 'Lamp'
          - type: glance
            title: Climate Control
            entities:
                - entity: switch.livingroomfan
                  tap_action: toggle
                  hold_action: more-info
                - entity: input_boolean.fanautolr
                  tap_action: toggle
                  hold_action: more-info
                  name: 'Auto'
                - entity: switch.livingroomairconditioner
                  tap_action: toggle
                  hold_action: more-info
                - entity: input_boolean.acautolr
                  tap_action: toggle
                  hold_action: more-info
                  name: 'Auto'
          - type: thermostat
            entity: climate.living_room_air_conditioner
          - type: glance
            entities:
                - sensor.illumination_158d0001e0acf6
                - sensor.illumination_7811dcdef518
                - sensor.living_room_temperatura
                - sensor.living_room_umidita
          - type: custom:mini-media-player
            entity: media_player.living_room_speaker_3
            artwork: cover
            show_source: true
            show_progress: true
            show_shuffle: true

#492

Excellent job @gurbina93. It looks really nice!

Would you mind sharing your automations? I am interested in how you control your AC on/off with the door sensor and how you automate the FAN/AC with motion/presence detection.


#493

Using the door sensor like this is genius!


#494

Just configured this component, it is great! Using it for my dumb TVs.
Just a question: I exposed the domain media_player to google assistant, but in google home I see the TVs as switches, and can only turn them on and off. Is it impossible to control volume and channels via voice?


#495

As easy as this one, they are all the same to turn on, just different entity or amount of minutes before turning it off.

Do note I face issues where the Broadlink IR codes just vanish in the air, they just do NOT make it to the AC so my automations used to fail, now I came up with a solution, basically I run the same sequence twice with a small delay in between to give my AC enough to close or open the louver (and my door sensor acts as the power state).
So for example the automation that turns off my AC sends the IR code but it does NOT make it, as per my automation below I just have a 15 second delay and run the same sequence again (which also checks for the power state before sending the IR signal).
For RF I don’t have any issues, which I use for the Broadlink TC2 switches which control lights and fans.
This is the AC switch with a Xiaomi Door Sensor for power state (open is On, closed is off)

This is the template switch(which as you can see uses the same IR code for on/off):

  livingroomairconditioner:
    value_template: "{{ is_state('binary_sensor.door_window_sensor_158d000288e2ed', 'on') }}"
    turn_on:
      - service: switch.broadlink_send_packet_192_168_0_102
        data:
          packet: 
            - "JgCWAAABQgABQQABQQABQZdSCw0MHwohCw0LIAsOCg0NCwsNDh0LDQsODB4LDA8LCiELDQ0LCwwPCwoOCg4KDgoOCw0KDg0LCyALDQsNDQsMDQwMCg4KDgoOCiALDQ4LCg4LDQoODAwLDQ0eCw4LDQoOCiALDgogCw4KDg0eCw0LDQsKEB4LIAsgCyALDgoOCg4KAAKcmAANBQAA="
    turn_off:
      - service: switch.broadlink_send_packet_192_168_0_102
        data:
          packet: 
            - "JgCWAAABQgABQQABQQABQZdSCw0MHwohCw0LIAsOCg0NCwsNDh0LDQsODB4LDA8LCiELDQ0LCwwPCwoOCg4KDgoOCw0KDg0LCyALDQsNDQsMDQwMCg4KDgoOCiALDQ4LCg4LDQoODAwLDQ0eCw4LDQoOCiALDgogCw4KDg0eCw0LDQsKEB4LIAsgCyALDgoOCg4KAAKcmAANBQAA="

Automations:
Please do note that for the bedroom I do not want the AC to turn off automatically when I am sleeping so I just set a time condition to avoid the AC turning off while I am asleep as there might not be any movement in the room to report to the Motion Sensors which trigger my automations.
The binary_sensor.motion_sensor_XXXX are my Xiaomi Aqara Motion sensors.


- alias: LivingRoomACOnPresence
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d0001e0acf6 
        to: 'on'
    condition:
      - condition: state
        entity_id: switch.livingroomairconditioner
        state: 'off'
    action:
      - service: switch.turn_on
        entity_id: switch.livingroomairconditioner

  - alias: LivingRoomACOffIfAway
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d0001e0acf6 
        from: 'on'
        to: 'off'
        for:
         minutes: 45
    action:
      - service: script.aclroff
      - delay: '00:00:15'
      - service: script.aclroff

  - alias: BedroomACOffIfAway
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d0001e5cc4e
        from: 'on'
        to: 'off'
        for:
         minutes: 45
    condition:
      - condition: state
        entity_id: switch.bedroomairconditioner
        state: 'on'
      - condition: time
        after: '11:00:00'
        before: '09:00:00'
    action:
      - service: switch.turn_off
        entity_id: switch.bedroomairconditioner
      - delay: '00:00:45'
      - service: script.acbroff

As for the scripts:


  aclroff: 
        sequence:
          - condition: state
            entity_id: switch.livingroomairconditioner
            state: 'on'
          - service: switch.turn_off
            entity_id: switch.livingroomairconditioner
  acbroff: 
        sequence:
          - condition: state
            entity_id: switch.bedroomairconditioner
            state: 'on'
          - service: switch.turn_off
            entity_id: switch.bedroomairconditioner

#496

Hi,
I am using the climate component successfully for a while now, and i was wondering if I can use the same broadlink device with two different components (climate & media)?

Basically I have the climate and smart TV in the same room, and I am wondering if it is possible to use both components using the same IR Mini.


#497

Yes you can. I’m already using it that way


#498

it worked perfectly. I have actually configured 2 media components, 1 climate and multiple switches on the same IR Mini.

Great work really.


#499

Hi, did you create the sanyo.ini file? I can’t find it on the components code list, I was wondering if you uploaded it somewhere? I also have a Sanyo.


#500

I also have this kind of device from Sanyo. Did you ever find out how to do this?


#501

Dear all,
I configured my IR fan (Panasonic F-60TAN) in hassio howerver, after replacing/ adding codes in the "ceiling_fan.ini" (replacing "low, medium, medium_hight, high, highest" by 1, 2, 3, 4, 5, 6, 7, 8, 9" with their ir codes) and my configuration.yaml codes below:

fan:

  • platform: broadlink
    name: Ceiling Fan
    host: 192.168.31.146
    mac: ‘B4:43:1D:A8:26:D9’
    rfcodes_ini: ‘custom_components/fan/broadlink_fan_codes/ceiling_fan.ini’
    default_speed: 5
    #defaut_direction: left
    customize:
    speeds:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    Then I test but there are only speeds from 1-5 work (RM Pro fires and orange light lit), speed 6, 7, 8, and 9: There’s no indication shown that it works: No light shown.
    Anyone know the reasons and how to cure it???
    P/S: Attached is the configuration in the

ceiling_fan.ini

file
Thanks for your reading
Minh Chau


#502

Hi,
Any idea why i cant load the custom component?
First time for me using a custom component and I’m running Hassio.

Log:
2018-12-11 20:46:33 ERROR (SyncWorker_1) [homeassistant.loader] Error loading custom_components.climate.broadlink. Make sure all dependencies are installed
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/loader.py”, line 92, in get_component
module = importlib.import_module(path)
File “/usr/local/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/climate/broadlink.py”, line 14, in
from homeassistant.helpers.restore_state import RestoreEntity
ImportError: cannot import name ‘RestoreEntity’
2018-12-11 20:46:33 ERROR (SyncWorker_1) [homeassistant.loader] Unable to find component climate.broadlink
2018-12-11 20:47:28 ERROR (MainThread) [homeassistant.components.hassio] INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4
Testing configuration at /config
Failed config
General Errors:
- Platform not found: climate.broadlink


#503

Hi, you are using the latest code which is compatible only with the upcoming version 0.84.X. Please use this code instead, but remember to update again when you install 0.84


#504

This is a great idea, I am going to implement this ASAP. Thanks


#505

aha, thanks! I will give it a try :slight_smile:


#506

For me it is broken in 0.84 (Docker/Hassio):

2018-12-12 23:47:24 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.climate.broadlink. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/climate/broadlink.py", line 14, in <module>
    from homeassistant.helpers.restore_state import async_get_last_state
ImportError: cannot import name 'async_get_last_state'
2018-12-12 23:47:24 ERROR (MainThread) [homeassistant.loader] Unable to find component climate.broadlink

#507

Yep. I’m getting the same error in 0.84.1 VENV.


#508

Check the new version on Github, it worked for me.

“Restore states through a JSON store instead of recorder (HA 0.84)”


#509

Thanks mate. Working again. :+1:


#510

Hi there,

Great work!

Anyone got this working with Toshiba air conditioners? I have a Toshiba RAS-13N3 split system and would like to control it via HA.

Cheers,
Pete