#Creating a notification compatible with this automation that dumps text to a robot TTS engine

1 messages · Page 1 of 1 (latest)

grave herald
#

configuration.yaml

rest_command:
  assume_behavior_control:
    url: 'http://10.0.0.111:8080/api-sdk/assume_behavior_control?priority=high&serial=00######'
    method: 'get'
  say_text:
    url: 'http://10.0.0.111:8080/api-sdk/say_text?text={{ states("textvector") }}&serial=00######'
    method: 'get'
  release_behavior_control:
    url: 'http://10.0.0.111:8080/api-sdk/release_behavior_control?priority=high&serial=00######'
    method: 'get'

Automation

alias: Vector Speech
description: Send text to Vector URL
trigger:
  - type: opened
    platform: device
    device_id: somedevice
    entity_id: someentity
    domain: binary_sensor
condition: []
action:
  - service: rest_command.assume_behavior_control
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: rest_command.say_text
    data:
      textvector: "Your family room lights are off"
  - delay: "00:00:10"
  - service: rest_command.release_behavior_control
    data: {}
mode: single

How would I get the automation to be used like a standard notification?

So I could just go into my other notification group and dump this unit into it as well?

- name: ALL_DEVICES
  platform: group
  services:
    - service: mobile_app_1
    - service: mobile_app_iphone
    - service: mobile_app_android
    - service: mobile_app_iphone2
    - service: alexa_media_vector
    - service: desktop_1
    - service: desktop_2
    - service: robot_vector #<= add it like this

example

service: notify.ALL_DEVICES
data:
  message: Your family room lights are off
grand vault
grave herald
#

I can check with the developer but they told me the api that I am using was never meant for external use and is undocumented

#

Doesn't look like it.

#

Hmm seem auth.js says jsonResp = JSON.parse(response)

#
function sayText() {
    sayTextValue = document.getElementById("textSay").value
    sendForm("/api-sdk/say_text?text=" + sayTextValue)
}
grand vault
#

I would try playing around with the notify service to see if you can get something to work:


notify:
  - name: robot_vector
    platform: rest
    resource: "http://10.0.0.111:8080/api-sdk/say_text"
    method: GET
    data:
      text: 'test 1 2 3'
      serial: '00######'
grand vault
#

The other alternative is command_line which supports templates. For example:

command_line:
  - notify:
      name: robot.vector
      command: 'curl http://10.0.0.111:8080/api-sdk/say_text?text={{ text }}&serial=00######'
grand vault
#

Actually the message is passed on stdin so I’m guessing maybe this:

command_line:
  - notify:
      name: robot.vector
      command: 'curl http://10.0.0.111:8080/api-sdk/say_text?text=${cat}&serial=00######'
#

I’m just grasping at straws, hopefully you can get some other help. With a question like this you may have better luck on the forums

grave herald
#

No worries I tried some stuff

notify.yaml

- platform: command_line
  name: vector
  command: "curl -X POST -H 'Authorization: Bearer LongLiveToken' -H 'Content-Type: application/json' -d '{"message": "{{ text }}"}' http://HAIP:8123/api/services/script/vector_speech"

scripts.yaml

vector_speech:
  sequence:
    - service: rest_command.assume_behavior_control
    - delay: "00:00:01"
    - service: rest_command.say_text
      data:
        textvector: "{{ message }}"
    - delay: "00:00:10"
    - service: rest_command.release_behavior_control

configuration.yaml

# Vector TTS
rest_command:
  assume_behavior_control:
    url: 'http://wirepodip:8080/api-sdk/assume_behavior_control?priority=high&serial=00######'
    method: 'get'
  say_text:
    url: 'http://wirepodip:8080/api-sdk/say_text?text={{ textvector }}&serial=00######'
    method: 'get'
  release_behavior_control:
    url: 'http://wirepodip:8080/api-sdk/release_behavior_control?priority=high&serial=00######'
    method: 'get'

Automation

alias: Vector Speech
description: Send text to Vector URL
trigger:
  - type: opened
    platform: device
    device_id: DEVICEID
    entity_id: ENTITYID
    domain: binary_sensor
condition: []
action:
  - service: notify.vector
    data:
      message: Your family room lights are off
mode: single

Test works

curl -X POST -H "Authorization: Bearer LongLiveToken" -H 'Content-Type: application/json' -d '{"message": "This is a test"}' http://HAIP:8123/api/services/script/vector_speech
#
[{"entity_id":"script.vector_speech","state":"on","attributes":{"last_triggered":"2024-01-23T19:07:17.420700+00:00","mode":"single","current":1,"friendly_name":"vector_speech"},"last_changed":"2024-01-23T19:07:17.420729+00:00","last_updated":"2024-01-23T19:07:17.420729+00:00","context":{"id":"SOMEID","parent_id":null,"user_id":"SOMEID"}},{"entity_id":"script.vector_speech","state":"on","attributes":{"last_triggered":"2024-01-23T19:07:17.420700+00:00","mode":"single","current":1,"last_action":"delay 0:00:01","friendly_name":"vector_speech"},"last_changed":"2024-01-23T19:07:17.420729+00:00","last_updated":"2024-01-23T19:07:18.223912+00:00","context":{"id":"SOMEID","parent_id":null,"user_id":"SOMEID"}},{"entity_id":"script.vector_speech","state":"on","attributes":{"last_triggered":"2024-01-23T19:07:17.420700+00:00","mode":"single","current":1,"last_action":"delay 0:00:10","friendly_name":"vector_speech"},"last_changed":"2024-01-23T19:07:17.420729+00:00","last_updated":"2024-01-23T19:07:20.664861+00:00","context":{"id":"SOMEID","parent_id":null,"user_id":"SOMEID"}}]
Failed to reload configuration
Cannot quick reload all YAML configurations because the configuration is not valid: Error loading /config/configuration.yaml: while parsing a block mapping in "/config/notify.yaml", line 6, column 3 expected <block end>, but found '<scalar>' in "/config/notify.yaml", line 8, column 279

Not sure how to format that curl url in notify.yaml to fix this error.

grand vault
#

If you are going to POST to your HA instance, why not just set up the rest notify service to do that?


notify:
  - name: robot_vector
    platform: rest
    resource: http://HAIP:8123/api/services/script/vector_speech
    method: POST_JSON
    headers:
      Authorization: !secret ha_token
      content-type: application/json
grave herald
#

hmm

#

notify.yaml

- name: vector
  platform: rest
  resource: http://HAIP:8123/api/services/script/vector_speech
  method: POST_JSON
  headers:
    Authorization: !secret vector_llatoken
    content-type: application/json
#
Logger: homeassistant.components.rest.notify
Source: /usr/src/homeassistant/homeassistant/components/rest/notify.py:223
Integration: RESTful (documentation, issues)
First occurred: 12:31:49 AM (1 occurrences)
Last logged: 12:31:49 AM

Client error. Response 401: Unauthorized:
NoneType: None
grave herald
#
Logger: homeassistant.components.http.ban
Source: components/http/ban.py:129
Integration: HTTP (documentation, issues)
First occurred: 1:20:13 AM (1 occurrences)
Last logged: 1:20:13 AM

Login attempt or request with invalid authentication from homeassistant (HAIP). Requested URL: '/api/services/script/vector_speech'. (HomeAssistant/2024.1.5 httpx/0.26.0 Python/3.11)
#

I don't know if it mattered but I added Authorization: Bearer !secret vector_llatoken but still got the same issue tried to re-enter the token again just in case and double checked the digits but still same errors

grave herald
grave herald
#

Apparently you can't use command_line under notify.yaml and you have to use command_line then pass it -notify so adding this when I run the automation it reads the template name instead of what I put in message of the automation he says "vectortext"

configuration.yaml

command_line:
  - notify:
      name: vectortts
      command: "curl -X POST -H 'Authorization: Bearer LongLiveToken' -H 'Content-Type: application/json' -d '{\"message\": \"{{ vectortext }}\"}' http://HAIP:8123/api/services/script/vector_speech"