I have a light that I can query the on/off state and also send commands via TCP. What I’d like to do is when a button is pressed, that command is sent and the light state changes.
I’ve tried a few approaches all of which have failed. I’ve tried to setup a service using the TCP setup in configuration.yaml but this only exposes the service as a state. I then tried to setup a ‘switch’ using TCP, but still the switch wasn’t shown in the action category of the automation.
Then I tried to create a shell_command alias and use that in the automation action, but get an error that ‘shell_command’ isn’t allowed.
Does anyone have any tips on the best way I can setup Home Assistant so that it can call a shell script whenever a button is pressed? Links to code or demo code would be super helpful.
The error is: " The automation “Light on in Office” (automation.light_on_in_office) has an action that calls an unknown service: shell_command.office_light_lamp_on."
None of the above as exposed in the automation UI
automation yaml:
alias: Light on in Office
description: test
trigger:
- device_id: xxx
domain: hue
platform: device
type: initial_press
subtype: 1
unique_id: xxx
condition: []
action:
- service: shell_command.office_light_lamp_on
mode: single
I’m far from an expert on this topic, but I do have several working shell scripts in my setup, and from what I know, that doesn’t appear to be the correct use of shell_command (unless the part you’ve omitted with ‘xxx’ actually correctly identifies your script - which makes helping you more challenging by not providing all the info… ?)
From my configuration.yaml:
shell_command:
yamaha_tuner: /bin/bash /config/scripts/yamahatuner.sh tune {{ ip }} {{ station }}