Shell command not working

Hi,

I can’t get homeassistant to run a shell cmd.

My configuration.yaml:

switch:

  • platform: wake_on_lan
    mac_address: “90-2B-34-1D-DC-38”
    name: ‘Computer Cinema’
    host: 10.0.0.15
    input: donald-pc
    turn_off:
    service: shell_command.test_hass_test

shell_command:
test_hass_test: ‘/usr/bin/sudo /usr/bin/touch /tmp/hasshass.txt’

Running homeassistant on Ubuntu Server

oot@ubuntu-server:/usr/share/homeassistant/config# uname -a
Linux ubuntu-server.flissinger.local 4.4.0-119-generic #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu-server:/usr/share/homeassistant/config#

Who can help me out? There are no errors in the log of homeassistant.
homeassistant is in the sudoers group, and is running under user homeassistant.
Where to search and find the problem?

Regards,
Donald.

Homeassistant or hassio?

Have you tried just

shell_command:
  test_hass_test: ‘touch hasshass.txt’

To see if it creates the file in the main directory?

Have you whitelisted the directory you’re trying to save to?

Umm, probably more questions to follow…

It’s homeassistant 0.67.1

Path to configuration.yaml: /usr/share/homeassistant/config
Built using Python 3, Polymer 2.6.0, Icons by Google and MaterialDesignIcons.com.
Frontend JavaScript version: latest

Yes, also tried just ‘touch hasshass.txt’
The file is not created.

Any error with that as the shell script?

I don’t know, touch isn’t a shell script, what I want to do is turn a windows 10 pc off with the turn_off cmd, when I run the shell script from the cli as user ‘homeassistant’ it works and the computers shuts down.

Could you have a look please? Going to really struggle debugging this with no information.

Homeassistant isn’t logging any error related to the switch, even with the debug logger on in configuration.yaml

What I have in configuration.yaml

logger:

switch:

  • platform: wake_on_lan
    mac_address: “90-2B-34-1D-DC-38”
    name: ‘Computer Cinema’
    host: 10.0.0.15
    turn_off:
    service: shell_command.turn_off_computer_cinema

shell_command: !include shell_commands.yaml

What I have in shell_commands.yaml:

turn_off_computer_cinema: ‘/usr/share/homeassistant/config/shellcommands/turnoffcomputercinemawindows.sh “Turning off Computer Cinema”’

What I have in turnoffcomputercinemawindows.sh:
#!/bin/bash
/usr/bin/net rpc shutdown -f -t 0 -I 10.0.0.15 -U donald%mypasswordisinhere

Owner and group of all files within /usr/share/homeassistant and subdirs is ‘homeassistant’
executable bit is set for the turnoffcomputercinemawindows.sh

When I run the turnoffcomputercinemawindows.sh from cli as user ‘homeassistant’ it does work.

What happens if you delete the quoted string from the end of the shell command?

What happens if you fire the shell command from the dev panel?

If I delete the quoted string “Turning off Computer Cinema” from cmdline it doesn’t work either.
When I fire the shell command from the dev panel it does work and the pc shuts down.

Snippet of debug log when turned off switch.

2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 140291954068784: Received {'type': 'call_service', 'domain': 'homeassistant', 'service': 'turn_off', 'service_data': {'entity_id': 'switch.computer_cinema'}, 'id': 11}
2018-04-23 19:43:13 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613568 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613600 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613520 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613504 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613584 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613344 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613488 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613536 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613408 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613312 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613328 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613456 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613296 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613616 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613632 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613440 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613648 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613664 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613680 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613696 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613712 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613728 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613744 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613760 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613776 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613792 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613808 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613824 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613840 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613856 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613872 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613888 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613904 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613920 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613936 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613952 FORWARDING <Event call_service[L]: domain=homeassistant, service=turn_off, service_data=entity_id=switch.computer_cinema, service_call_id=140292502390544-26>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613568 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613600 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613520 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613504 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613584 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613344 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613488 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613536 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613408 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613312 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613328 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613456 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613296 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613616 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613632 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613440 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613648 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613664 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613680 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613696 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613712 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613728 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613744 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613760 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613776 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613792 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613808 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613824 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613840 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613856 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613872 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613888 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613904 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613920 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613936 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613952 WRITING data: {"event_type": "call_service", "data": {"domain": "homeassistant", "service": "turn_off", "service_data": {"entity_id": "switch.computer_cinema"}, "service_call_id": "140292502390544-26"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.503354+00:00"}
2018-04-23 19:43:13 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613568 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613600 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613520 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613504 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613584 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613344 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613488 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613536 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613408 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613312 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613328 FORWARDING <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=['switch.computer_cinema'], service_call_id=140292502390544-27>
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613456  WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613744 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613760 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613776 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613792 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613808 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613824 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613840 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613856 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613872 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613888 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613904 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613920 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613936 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 DEBUG (MainThread) [homeassistant.components.api] STREAM 140291988613952 WRITING data: {"event_type": "call_service", "data": {"domain": "switch", "service": "turn_off", "service_data": {"entity_id": ["switch.computer_cinema"]}, "service_call_id": "140292502390544-27"}, "origin": "LOCAL", "time_fired": "2018-04-23T17:43:13.529681+00:00"}
2018-04-23 19:43:13 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140292502390544-27>
140291954068784: Sending {'id': 11, 'type': 'result', 'success': True, 'result': None}

I don’t know why the above script/cmd didn’t work, but here is how I got it to work:

In configuration.yaml:


switch:
  - platform: wake_on_lan
    mac_address: "90-2B-34-1D-DC-38"
    name: 'Computer Cinema'
    host: 10.0.0.15
    turn_off:
     - service: script.turn_on
       data:
         entity_id: script.turn_off_computer_cinema

script: !include scripts.yaml
shell_command: !include shell_commands.yaml

in scripts.yaml:

turn_off_computer_cinema:
  alias: 'Turn off cinema computer'
  sequence:
  - service: shell_command.turn_off_computer_cinema

in shell_commands.yaml:

turn_off_computer_cinema: '/usr/share/homeassistant/config/shellcommands/turnoffcomputercinemawindows.sh "Turning off Computer Cinema"'

in turnoffcomputercinemawindows.sh:

#!/bin/bash
/usr/bin/net rpc shutdown -f -t 0 -I 10.0.0.15 -U donald%mypasswordisinherewithescapecharacters

Isn’t there an easier way? Or is this the way it should?

Thanks for your help @anon43302295

If it works for the script it should work as the action for the switch, if it definitely doesn’t then looks like a bug and will need reporting on GitHub :+1: