#Having issues passing commands from scripts into my shell command

1 messages · Page 1 of 1 (latest)

last ocean
#

hey guys,

I have a shell command that should be sending commands received from my various scripts though unfortunately I cant seem to figure out why they wont actually pass through. Been trying to use sockets to pass these commands through.
I can SSH from my PC and run commands just fine, though cant get it to go from HA.

Basically this is the setup; Button> Script > Shell command > Script > Telnet commands > Audio processor

config.yaml:

shell_command:
  dsp_telnet: 'echo "{{ command }}" | /usr/bin/nc 127.0.0.1 65432'

one of the scripts as a guide for how i have them setup:

zone1_source1:
  alias: Zone 1 Source 1
  sequence:
    - action: shell_command.dsp_telnet
      data:
        command: "SourceSelector1 set sourceSelection 1"
    - action: input_select.select_option
      data:
        option: Source 1
      target:
        entity_id: input_select.zone1

I get this in my logs from when the script starts:
[2024-11-27 00:12:10] Creating new Telnet connection...
[2024-11-27 00:12:10] Command listener running on 0.0.0.0:65432
[2024-11-27 00:12:13] Telnet connection established.

Heres my button yaml incase:

type: vertical-stack
cards:
  - type: custom:bubble-card
    card_type: pop-up
    hash: "#source1"
    name: Source 1
    show_header: false
  - type: custom:bubble-card
    card_type: separator
    name: Source 1
    icon: mdi:bluetooth-audio
  - type: custom:bubble-card
    card_type: button
    button_type: state
    entity: binary_sensor.zone1_source1
    show_state: false
    name: Zone 1
    button_action:
      tap_action:
        action: call-service
        target: {}
        service: script.zone1_source1
      double_tap_action:
        action: none
      hold_action:
        action: none
    tap_action:
      action: none
    double_tap_action:
      action: none
    hold_action:
      action: none

I for the life of me cant figure this out, if anyone has any guidance id be forever in your debt.

quasi zodiacBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

last ocean
# quasi zodiac

Ah amazing thank you so much for that. I did look to see if I could format code but didn’t know about the backtick. Fixed up, thanks!

last ocean
#

Anyone at all?

acoustic harbor
#

My advice is to start small and work your way up. Start with the shell command only, without templates, and call it from developer tools -> actions.

shell_command:
  dsp_telnet: 'echo "SourceSelector1 set SourceSelection 1" | /usr/bin/nc 127.0.0.1 65432'

If you can get that to work, then add the template back in, and call it from dev tools again, this time specifying the command, and see if it works. Keep building it up so that you know what to focus on when it breaks.

last ocean
hazy knot
#

What do you have running on the HA container listening on 65432 ? I feel like that's incorrectly specified

#

(Assuming you're running HA OS or Container, but specify if you are not)