-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] 'request:' to be able to parse variables #3
Comments
Can you try again after restarting home assistant? |
I've restarted it multiple times. It works if i write out the exact string like this trigger:
- platform: event
event_type: google_assistant_sdk_custom_event
id: response
event_data:
request: what temperature is the ac at what i wanted is to have it take a |
I don't think you can have templates in triggers. You can just remove the event_data from your trigger. And you can have if then actions where in the if you can have templates based on trigger.event.data.request |
Thank you for your support! i've managed to make it work. UPDATE 11.24.2023: If anyone is having problem with the event not triggering the automation:I don't know if it's a bug or a rewrite, but after reinstalling the integraton, the automations stopped working. Turns out that the here's the updated code: alias: AC sync
description: >-
This automation is resposible for syncing any non HA change made on a Hisense
smart air conditioning unit, (namely on/off state and target temperature) the
response gets regexed to its core components then gets synced with a dummy
generic thermostat.
trigger:
- platform: event
event_type: automation reloaded
- platform: event
event_type: google_assistant_sdk_custom_custom_event
event_data: {}
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: "{{trigger.event.data.request == 'is the ac on'}}"
alias: Ac state check
sequence:
- alias: regex response and set it as ''state'' variable
variables:
state: "{{trigger.event.data.response|regex_findall_index('on|off')}}"
- alias: choose the on/off service
service_template: >-
{% if state == 'on' %} climate.turn_on {% elif state == 'off' %}
climate.turn_off {% else %} stop {% endif %}
data: {}
target:
entity_id: climate.baja_klima
- conditions:
- alias: Ac temperature check
condition: template
value_template: >-
{{trigger.event.data.request == 'what temperature is the ac set
to' and trigger.event.data.response != 'Sorry, I couldn\'t reach
ConnectLife.' and states('climate.baja_klima') != 'off'}}
- condition: template
value_template: >-
{{state_attr('climate.baja_klima','temperature')|round(0) !=
trigger.event.data.response|regex_findall_index('[0-9]{2}')|round(0)}}
sequence:
- service: climate.set_temperature
data:
temperature: "{{trigger.event.data.response|regex_findall_index('[0-9]{2}')}}"
target:
entity_id: climate.baja_klima
default:
- stop: unhandled exception
mode: single The second part of the automation: alias: Baja klíma control
description: >-
This automation makes changes on the Hisense air conditioning unit based on
the dummy Generic thermostat. Also it tries to update thegeneric thermostat
every 5 minutes if there was a change that is not made by HA (I.E using the
remote or the default smart home app)
trigger:
- platform: state
entity_id:
- climate.baja_klima
attribute: temperature
id: temp
- platform: state
entity_id:
- climate.baja_klima
id: "off"
to: "off"
- platform: state
entity_id:
- climate.baja_klima
from: "off"
id: "on"
- platform: time_pattern
minutes: /5
id: time
- platform: event
event_type: automation_reloaded
id: time
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: temp
sequence:
- service: google_assistant_sdk_custom.send_text_command
data:
command: >-
Change klíma temperature to
{{state_attr('climate.baja_klima','temperature')}} C
- conditions:
- condition: trigger
id: "on"
sequence:
- service: google_assistant_sdk_custom.send_text_command
data:
command: turn on Klíma
- conditions:
- condition: trigger
id: "off"
sequence:
- service: google_assistant_sdk_custom.send_text_command
data:
command: turn off Klíma
- conditions:
- condition: trigger
id: time
sequence:
- service: google_assistant_sdk_custom.send_text_command
data:
command: is the ac on
- wait_for_trigger:
- platform: state
entity_id:
- automation.baja_klima_sync
to: "0"
for:
hours: 0
minutes: 0
seconds: 0
attribute: current
timeout:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: google_assistant_sdk_custom.send_text_command
data:
command: what temperature is the ac set to
- wait_for_trigger:
- platform: state
entity_id:
- automation.baja_klima_sync
to: "0"
for:
hours: 0
minutes: 0
seconds: 0
attribute: current
timeout:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
mode: single |
I am trying to make a google home compatible device work with HA using the google assistant sdk and a generic thermostat.
I tried to debug how it would work but the event never gets fired:
the entities are 2 text inputs (one for the request and one for the response)
the script
the automation that should catch the response:
I can see my responses in the https://myactivity.google.com/myactivity yet the automation never gets triggered and starting it manually does not result any response
[edit] I also tried handling the request and response commands in a single automation using a wait_for event flow, but that does nots seem to fix the problem either.
[edit] fater further testing it seems that the 'request:' object does not parse any variables. Is there a way to change that? It would make it much more flexible when it comes to other devices.
The text was updated successfully, but these errors were encountered: