GithubHelp home page GithubHelp logo

Comments (4)

tronikos avatar tronikos commented on June 9, 2024

Can you try again after restarting home assistant?

from google_assistant_sdk_custom.

Netesfiu avatar Netesfiu commented on June 9, 2024

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 {{states('input_text.name')}} as request object so i dont need to hard-code every possible request

from google_assistant_sdk_custom.

tronikos avatar tronikos commented on June 9, 2024

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

from google_assistant_sdk_custom.

Netesfiu avatar Netesfiu commented on June 9, 2024

Thank you for your support! i've managed to make it work.
posting the working code if anyone else is struggling to make google home only compatible devices work with HA

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 event_type that would trigger the automation name changed from google_assistant_sdk_custom_event to google_assistant_sdk_custom_custom_event. If anyone experiencing the automation not getting triggered by the google_assistant_sdk_custom_event try adding google_assistant_sdk_custom_custom_event as a 3rd trigger condition.

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

from google_assistant_sdk_custom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.