syssi / chuangmi_ir

Xiaomi Zhimi Floor Fan and Chuangmi IR Controller integration for Home Assistant
27 stars 5 forks source link

Switch in Xiaomi IR remote doesn't show up #10

Closed kukki closed 6 years ago

kukki commented 6 years ago

chuangmi_ir.py commit version: c813877 hass version: 0.63.3

Switch.yaml:

- platform: chuangmi_ir
  host: !secret chuangmi_ip
  name: "Xiaomi IR"
  token: !secret chuangmi_key
  switches:
    tv:
      command_on: 'Z6XHAKYBAAAqBQAAnAYAAJsNAAC2Dxxxxxxxxxxxxxxxxx'
      command_off: 'Z6XHAKYBAAAqBQAAnAYAAJsNAAC2Dxxxxxxxxxxxxxxxxx'

Issue:

Observed:

syssi commented 6 years ago

HA 0.63.3 supports the device. The custom component isn't needed anymore:

https://home-assistant.io/components/remote.xiaomi_miio/

kukki commented 6 years ago

xiaomi_miio can only use the IR as script command. What I want is a switch. Is there any way to use it as switch with xiaomi_miio?

syssi commented 6 years ago

Hmm... good question. :-) I don't know if I'm honest.

syssi commented 6 years ago

Let's fix this component! ;-)

syssi commented 6 years ago

Please enable the debug output of this component


logger:
  default: warn
  logs:
    custom_components.switch.chuangmi_ir: debug

And provide your home-assistant.log. Does it show something about the missing switch?

kukki commented 6 years ago

There is no error or warning about missing switch. There is only one INFO line for custom_components in log:

2018-02-23 16:11:31 INFO (Thread-2) [custom_components.switch.chuangmi_ir] Initializing with host 192.168.1.161 (token 34784...)

It was odd. At the meantime, I add name attribute to the chuangmi_ir sub-switch. And it appears in the lists mentioned above. So current workaround for me is to just add the name attribute like this:

- platform: chuangmi_ir
  host: !secret chuangmi_ip
  name: "Xiaomi IR"
  token: !secret chuangmi_key
  switches:
    tv:
      name: 'TV Power'
      command_on: 'Z6XHAKYBAAAqBQAAnAYAAJsNAAC2Dxxxxxxxxxxxxxxxxx'
      command_off: 'Z6XHAKYBAAAqBQAAnAYAAJsNAAC2Dxxxxxxxxxxxxxxxxx'

It appears as switch.tv_power

syssi commented 6 years ago

This is strange. The default name of a switch should be "chuang_mi_ir_switch".

https://github.com/syssi/chuangmi_ir/blob/master/custom_components/switch/chuangmi_ir.py#L28-L43