Hi all!
I have Hass.io 0.65.0 with the Google Assistant component running great, but I have created a script to turn on my TV and another one to turn it off using a Xiaomi Universal IR Remote that sends an IR code to the TV. These scripts work great if I fire them manually from HA, but if I ask Google: “Ok, Google: turn on the TV”, then it replies: “Got it, activating 2 things”. Then, what it actually does is to run both scripts! I don’t really know why.
Here is the relevant part of my configuration.yaml:
google_assistant:
project_id: [SECRET]
client_id: [SECRET]
access_token: [SECRET]
agent_user_id: [SECRET]
api_key: [SECRET]
exposed_domains:
- switch
- light
- script
remote:
- platform: xiaomi_miio
name: Xiaomi Miio
host: 192.168.1.60
token: [SECRET]
script:
turn_on_tv:
alias: Turn on the TV
sequence:
- data:
command: [LONG HEX COMMAND]
entity_id: remote.xiaomi_miio
service: remote.send_command
turn_off_tv:
alias: Turn off the TV
sequence:
- data:
command: [LONG HEX COMMAND]
entity_id: remote.xiaomi_miio
service: remote.send_command
I also recorded some logs of what actually happens when I call a script from Google Assistant:
2018-03-11 17:52:09 INFO (MainThread) [homeassistant.components.http.view] Serving /api/ to 172.30.32.2 (auth: True)
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.components.http.view] Serving /api/google_assistant to 66.102.9.45 (auth: True)
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=script.turn_off_tv, service_call_id=1968715504-36>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=script.turn_on_tv, service_call_id=1968715504-37>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_off_tv, service_data=None, service_call_id=1968715504-38>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1968715504-36>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on_tv, service_data=None, service_call_id=1968715504-39>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1968715504-37>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.helpers.script] Script Turn off the TV: Running script
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.helpers.script] Script Turn off the TV: Executing step call service
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=remote, service=send_command, service_data=command=[LONG HEX COMMAND], entity_id=remote.xiaomi_miio, service_call_id=1968715504-40>
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.helpers.script] Script Turn on the TV: Running script
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.helpers.script] Script Turn on the TV: Executing step call service
2018-03-11 17:52:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=remote, service=send_command, service_data=command=[LONG HEX COMMAND], entity_id=remote.xiaomi_miio, service_call_id=1968715504-41>
2018-03-11 17:52:11 DEBUG (SyncWorker_11) [homeassistant.components.remote.xiaomi_miio] Sending payload: '[LONG HEX COMMAND]'
2018-03-11 17:52:11 DEBUG (SyncWorker_19) [homeassistant.components.remote.xiaomi_miio] Sending payload: '[LONG HEX COMMAND]'
2018-03-11 17:52:11 DEBUG (SyncWorker_19) [miio.device] Discovered 02f1baf9 with ts: 1970-01-06 00:24:41, token: b'[SECRET]'
2018-03-11 17:52:11 DEBUG (SyncWorker_19) [miio.device] 192.168.1.60:54321 >>: {'id': 3, 'method': 'miIO.ir_play', 'params': {'freq': 38381, 'code': '[LONG HEX COMMAND]'}}
2018-03-11 17:52:12 DEBUG (SyncWorker_19) [miio.device] 192.168.1.60:54321 (ts: 1970-01-06 00:24:41, id: 3) << {'result': 0, 'id': 3}
As you can see, it calls script.turn_off_tv
first (which is correct), but then it also calls script.turn_on_tv
and I have no idea why.
Any ideas?
Thanks!