brebar07
(Brendan)
August 8, 2019, 11:14am
1
Hello All,
I hope someone can point me in the right direction. I have configured my Xiaomi remote and is connecting to my HASS but I am having problems learning commands and sending commands.
Learning commands, I am using developer tools and call service ‘remote.xiaomi_miio_learn_command’ after that I point AC remote at device and then I get the code. It seems that everytime I use this command, even when I push the same button on the remote it returns a different raw code. For example turn AC off here is 3 examples of the code learnt;
mczm8wlkxm02mEsmkyAIKZTUAgpmAQ4CJTSYgD+BTYDHgheAz4DKgZeBl4DPg3eAPAGXgdeAx4A/gD+AP4A/gD+AP4TOAL+AvgD/gD+AP4bHggeAP4A/gX2Iz4A9wAA=
mczm8wlkxm02mEsmkyAIKZTUAjppMQB/Ag8BjwQvAZ8DLwMvAZ8BnwIfAY8BjwGPAH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/DY8AfwB/AH8EDwB8gAA=
mczm8wlkxm02mEsmkzAIKZTQAjppMQB/Ag+YAMeCFE1AIKZAMsAOQKfgZeCp4IcBH+APAKiAQsAxAHUAY+AP4GHAouAPgF/gL+Bf4C/gL+Af4C/gL+AP4bHgD+Gh4A/ggeDz8AA=
My other problem is when I try to send command to the IR remote nothing happens (but I am guessing this is because the raw code is incorrect). I have tried completing this in configuration.yaml and also scripts.yaml
Any help would be greatly appreciated.
configuration.yaml
XIAOMI MI REMOTE v2:
remote:
platform: xiaomi_miio
name: mi_remote
host: 192.168.1.136
token: -secret token-
commands:
command:
- raw:mc0mMwlkxm0ymEsmk3AIKZTAAjpnNgB/Ag8BjwQvAZ8DLwMvAZ8BnwIfAY8BjwGPAH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/DY8AfwB/FE8CHwB9gAA=
scripts.yaml
turn_off_ac:
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- raw:mc0mMwlkxm0ymEsmk3AIKZTAAjpnNgB/Ag8BjwQvAZ8DLwMvAZ8BnwIfAY8BjwGPAH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/DY8AfwB/FE8CHwB9gAA=
turn_on_ac:
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- raw:mczm8wlkxm02mEsmkyAIKZTUAjppMQB/Ag8BjwQvAZ8DLwMvAZ8BnwIfAY8BjwGPAH8AfwB/AH8AfwB/AH8AfwB/Co8AfwB/Aw8AfwB/FF8CHwB+gAA=
1 Like
First of all please format your code properly with </>
You are using the data format incorrectly. It should be something like this
remote:
- platform: xiaomi_miio
name: "Woonkamer Remote"
host: 192.168.178.129
token: !secret mi_remote_token
commands:
decoder_commando_uit:
command:
- raw:nMwmEwlk0mk1mEsms4ADIAcwAymM2m4CCzGbAI+AioDXge+AhQA7gJmAP4A9gt2CT4FMAQ6Ah4KdhPQAogLnguSBtQcfzCWTCAA=
receiver_commando_aan:
command:
- raw:nMwmEwlk0mk1mEsms4ADIAcwAymM2m4CCzGbAI+AioDXge+AhQA7gJmAP4A9gt2CT4FMAQ6Ah4KdhPQAogLnguSBtQcfzCWTCAA=
And then to send the commands with your mi remote you should use something like this (please note i don’t use scripts but the remote command instead)
- service: remote.send_command #decoder uit
entity_id: 'remote.woonkamer_remote'
data:
command:
- 'decoder_commando_uit'
clyra
(Clyra)
August 8, 2019, 11:33am
3
Not sure if you did right, but my config looks a bit different. On xiaomi definition I have:
- platform: xiaomi_miio
host: 192.168.0.xxx
token: <token>
name: Living Room Remote
commands:
tv_power:
command:
-raw:Z6VvACoCAACUBgAAzQgAAJARAAAPIwAA9JcAAJx2AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0EBAQAAAAABAAEBAQEAAQAAAQAAAQAAAAEAAQEAAQEBBQJGAkYCRgJGAkAA==
and then to use it:
script:
tv_power:
alias: TV Power
sequence:
- service: remote.send_command
entity_id: 'remote.living_room_remote'
data:
command:
- 'tv_power'
brebar07
(Brendan)
August 8, 2019, 11:44am
4
Apologies for my initial formatting, and formatting code.
Thanks @Infineghost and @clyra I will try your recommends tonight and feedback to this post.
Is it normal to get different raw codes for the same command, I assumed it would be same?
Why would you learn two (2) codes for one (1) command. Just use one code to perform an action.
When learning the commands, the raw code can be different indeed. Just use one of the codes and in my experience they both work.
brebar07
(Brendan)
August 8, 2019, 11:58am
6
@Infineghost thanks for the information. I’ll try again tonight.
brebar07
(Brendan)
August 9, 2019, 9:07am
7
Seems to still fail;
if I call the script = nothing happens
if I call the entity-button = error "failed to call service remote/send_command. required key not provided @ data[‘comand’]
Any ideas?
configuration.yaml
remote:
- platform: xiaomi_miio
name: mi_remote
host: 192.168.xxx.xxx
token: <remote token>
commands:
turn_ac_off:
command:
- raw:mczm8wlkxm02mEsmkyAIKZTUAgpmAQ4CJTSYgD+BTYDHgheAz4DKgZeBl4DPg3eAPAGXgdeAx4A/gD+AP4A/gD+AP4TOAL+AvgD/gD+AP4bHggeAP4A/gX2Iz4A9wAA=
script.yaml
ac_turn_off:
alias: Turn off AC
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- turn_ac_off
lovelace entity-button
entity: remote.mi_remote
hold_action:
action: more-info
name: Turn Off AC
show_icon: true
show_name: true
tap_action:
action: call-service
service: remote.send_command
data:
command:
- turn_ac_off
type: entity-button
You seem to be missing an additional space between turn ac off and command, try it again with the additional space.
remote:
- platform: xiaomi_miio
name: mi_remote
host: 192.168.xxx.xxx
token: <remote token>
commands:
turn_ac_off:
command:
- raw:mczm8wlkxm02mEsmkyAIKZTUAgpmAQ4CJTSYgD+BTYDHgheAz4DKgZeBl4DPg3eAPAGXgdeAx4A/gD+AP4A/gD+AP4TOAL+AvgD/gD+AP4bHggeAP4A/gX2Iz4A9wAA=
Sames goes for your script.
I don’t know if it is another issue, but i always make sure i don’t got the same name twice. You use your remote name as ‘turn ac off’ but the same for your script. my recommendation would be never use the same name twice.
ac_turn_off:
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- 'turn_ac_off'
brebar07
(Brendan)
August 9, 2019, 12:59pm
9
I have updated configuration & script, thanks I should have caught that error. I when I call the script nothing happens and I got get anything in the log. The entity-button still gives me the same error
remote:
- platform: xiaomi_miio
name: mi_remote
host: 192.168.x.xxx
token: <secret token>
commands:
turn_off_ac:
command:
- raw:mczm8wlkxm02mEsmkyAIKZTUAgpmAQ4CJTSYgD+BTYDHgheAz4DKgZeBl4DPg3eAPAGXgdeAx4A/gD+AP4A/gD+AP4TOAL+AvgD/gD+AP4bHggeAP4A/gX2Iz4A9wAA=
ac_turn_off:
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- 'turn_off_ac'
I don’t know if your entity button is correct, i don’t think so as you should use quote marks as well there.
But are you 100% sure your RAW code is correct?. As it looks good to me, you could try your indentation different with the script, but that doesn’t seem a problem to me.
ac_turn_off:
sequence:
- service: remote.send_command
entity_id: remote.mi_remote
data:
command:
- 'turn_off_ac'
What does the log show?
Maybe a stupid question, but did you reload your script and restart HA?
brebar07
(Brendan)
August 9, 2019, 1:22pm
11
@Infineghost
yes I have reloaded script & restarted HA
I have also learnt another command just now and tried replacing that raw command
There is no error / entry in the log…
Seems very strange to me, can you add the following code to your config and fire up the script (not the entity button)
'1555789719863':
alias: ac_turn_off
sequence:
- service: remote.send_command
entity_id: 'remote.mi_remote'
data:
command:
- 'turn_off_ac'
brebar07
(Brendan)
August 9, 2019, 1:33pm
13
Found this error in the log just now
2019-08-09 23:25:33 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1810950928] Error handling message: required key not provided @ data['service']. Got None
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/connection.py", line 91, in async_handle
handler(self.hass, self, schema(msg))
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 267, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 589, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 427, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['service']
brebar07
(Brendan)
August 9, 2019, 1:41pm
14
what ever way I try to call the service with an entity-button I always get this error;
failed to call service remote/send_command. required key not provided @ data[‘comand’]
The errors shows something wrong with the service call, like i already told you before. It seems that the entity button is wrong.
But to exclude the script being wrong, you should first try activating your script
Infineghost:
Seems very strange to me, can you add the following code to your config and fire up the script (not the entity button)
Copy to clipboard
'1555789719863':
alias: ac_turn_off
sequence:
- service: remote.send_command
entity_id: 'remote.mi_remote'
data:
command:
- 'turn_off_ac'
Could you add your script to the GUI (frontend) and fire up only the script . See if that works, the entity button is one for later
brebar07
(Brendan)
August 9, 2019, 1:51pm
16
@Infineghost I have called that script directly from developer tools > services. No error in log, that indicates to be the service was called correctly and may be the raw code is incorrect, but I ive just learnt a new command and called it…
Im going to try one from my TV and see if this is isolated to my AC unit…
If there is no error with the script called directly, then your coding is correct there. As earlier mentioned, are you 100% sure your RAW code is correct?.
I would suggest playing around with some RAW codes of sort. And create multiple scripts for dedicated commands. And if those works you can see if a button entity can be created.
brebar07
(Brendan)
August 9, 2019, 1:59pm
18
Yes Ill have a play around with codes, I have just tried power for TV (different brand, etc) and I have the same result.
brebar07
(Brendan)
August 9, 2019, 2:05pm
19
can we inject the raw code directly in the script? For example;
off_test2:
alias: off2
sequence:
- service: remote.send_command
entity_id: 'remote.mi_remote'
data:
command:
- raw:mc0mMwlkxm0ymEsmk2AIKZAGkARkzm4A/gQeAx4IXgM+Bl4GXgM+Az4EPgMeAx4DHgD+AP4A/gDpOQBymgC/gD+AP4A/gD+AP4A/gD+Gx4EHgD+Bx4HHgD+AOUAA
Just thinking of other ways to test this…