syssi / xiaomi_airconditioningcompanion

Xiaomi Mi and Aqara Air Conditioning Companion integration for Home Assistant
Apache License 2.0
394 stars 93 forks source link

Need help to use IR command sending function with home assistant as an entity/device #119

Closed LiangZugeng closed 3 years ago

LiangZugeng commented 3 years ago

First of all, this component is amazing, thank you for creating it.

I'm quite new to Home Assistant, actually I just started playing it since yesterday.

The IR command learning and sending functions worked great, I tested it in Services in Developer Tools and it worked well, my scenario is to turn on/off a light which can be controlled by a IR remote, when I invoked the IR sending function with proper IR command in Developer Tools, the light turned on or off as expected.

As a new comer, the problem for me is how I can configure an entity or device in configuration.yaml file so I can have a "virtual" device (the light) on the dashboard with an on/off switch, thus when I manipulate the switch the on/off IR commands can be sent. BTW, I am intended to control it in HomeKit so I guess it needs to be a device or entity in HA (correct me if I'm wrong).

I understand I'm asking a home assistant related question here which may not be the concern of this component, but it will be much appreciated if I can get some hints or samples to achieve the goal as this represents a common use scenario for this component. Thank you very much in advance.

BTW, I have already added a AC device in configuration.yaml to control the AC and it works well.

climate living_room_ac:
  - platform: xiaomi_miio_airconditioningcompanion
    name: Living Room Air Conditioner
    host: 192.168.32.198
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    target_sensor: sensor.temperature_158d0001f53706
    scan_interval: 60
itispip commented 3 years ago

UI (control card) can be created through HA's own feature

But agree this component should add something to record down the "learnt command" somewhere...

LiangZugeng commented 3 years ago

Thank you @itispip

I figured that out and finished setting it up correctly in both HA and HomeKit, it turns out the HomeKit Hub I added to HA filtered all script entities out, after changed the filter settings the script entities I added for sending IR commands showed in HomeKit as a switch.

I have been using this for several days with some minor random issues though but those are separate topics, this issue can be closed.