Sian-Lee-SA / Home-Assistant-Switch-Manager

Switch manager is a centralised component to handle button pushes for your wireless switches. This includes anything passed through the event bus. The component relies on switch blueprints which is easily made to allow GUI configuration of your switches and their button pushes. This helps remove clutter from the automations.
Other
232 stars 85 forks source link

Calling service or scripts doesn't work #264

Closed michalg- closed 1 week ago

michalg- commented 1 week ago

Hey, I'm having trouble running a script or a TTS action through the creator in Switch Manager. I have a very simple script:

action: chime_tts.say
data:
  chime_path: bright
  tts_speed: 121
  tts_platform: google_translate
  cache: true
  language: pl
  message: Okej gaszę!
  volume_level: 0.7
target:
  device_id: 21dcd3d44fc1667886f82ea27ab51fd8

And it works in the developer console, but when I try to add it to a button action like:

- action: script.okej_gasze
- action: light.turn_off
  target:
    entity_id:
      - light.zarowka_jajko

I get an error in the console:

2024-10-08 19:25:59.600 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [3212426736] Error handling message: extra keys not allowed @ data['action']. Got {'action': 'script.okej_gasze', 'metadata': {}, 'data': {}} (invalid_format) Michal from 172.69.155.169 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15)

What am I doing wrong or what's the solution to this problem?

Sian-Lee-SA commented 1 week ago

What version of HA and Switch Manager are you running?

michalg- commented 1 week ago

HA Core: 2024.11.0.dev202410090229 Switch Manager: v2.0.0

I solved this problem moving actions to a automation and just call it on button press, but I think it should also work defining in the regular way.

Sian-Lee-SA commented 1 week ago

Works fine for me, Also version 2024.11 is currently unstable/beta/dev and not a stable release which is also not something that is supported

michalg- commented 1 week ago

Right, I forgot that I'm using the dev branch. Anyway, it looks like the issue is only related to the TTS actions, as all the others are executed as expected.

Sian-Lee-SA commented 1 week ago

Stange, TTS has been flaky for me in general throughout HA. Will see how things goes once a stable release is out etc and whether needs further investigating.

michalg- commented 1 week ago

@Sian-Lee-SA I downgraded to stable 2024.10.1 and still receiving the same error:

2024-10-10 09:29:37.679 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [3046419736] Error handling message: extra keys not allowed @ data['action']. Got {'action': 'automation.trigger', 'metadata': {}, 'data': {'skip_condition': True}, 'target': {'entity_id': 'automation.zgas_dol'}} (invalid_format) Michal from 192.168.68.103 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2024.9.2 (io.robbie.HomeAssistant; build:2024.881; macOS 14.7.1) Mobile/HomeAssistant, like Safari)

It's action for holding WXKG01LM button: Screenshot 2024-10-10 at 09 31 54

The error appears when I press 'Run' in the visual editor and also when I'm pressing the button.

Also automation is pretty straightforward:

alias: Zgaś światło na dole
description: ""
triggers: []
conditions: []
actions:
  - action: chime_tts.say
    data:
      chime_path: hail
      volume_level: 0.75
    target:
      entity_id: media_player.lenovo_cd_18781y
  - action: light.turn_off
    target:
      area_id:
        - kuchnia
        - salon
        - lazienka
        - przedpokoj
    data: {}
mode: single
Sian-Lee-SA commented 1 week ago

I can't seem to replicate your issue, I just did

action: automation.trigger
metadata: {}
data:
  skip_condition: true
target:
  entity_id: automation.christmas_lights_outside

and works fine, using run from web ui

Sian-Lee-SA commented 1 week ago

I also find it strange that you mention the issue is "also when I'm pressing the button." when the error log message relates to the UI and HTTP which the backend doesn't use when processing the button.

Also the issues related to the UI and selecting run etc is all throughthe HA core functions and modules, Switch Manager doesn't have control of those parts.