Controlling TV via python script does not work: Error 2


I have a python script which configures the background light of my television. If I call it via SSH on my Raspberry Pi which is running Home Assistant everything works like a charm:


I want to go a step further and want to run it via a Lovelace button, but this is not working. The error message is:

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/
Integration: Shell Command
First occurred: 1. Dezember 2020, 21:28:05 (6 occurrences)
Last logged: 11:15:24

Error running command: python3 "", return code: 2

NoneType: None

type: button
name: Fernseher dunkel
show_state: false
  action: call-service
  service: script.dark_tv
    entity_id: script.dark_tv
icon: 'hass:television'


      service: shell_command.tv_off
      service: shell_command.tv_dark


  tv_off: python3 -m samsungctl --host=192.168.x.x --name HomeAssistant KEY_POWEROFF
  tv_dark: python3 ""

The configuration.yaml contains a shell_command with the name “tv_off” which is working in contrast to “tv_dark”. The difference is that tv_off is only a single call to a python-module instead of a script.

I tried to chmod tv_brightness to 777 but this isnt helping. I also tried to place the files in different paths. Currently they are in /home/pi/.local/bin but I tried to place them in /usr/share/hasio/homeassistant/scripts also without luck.

The contents of the script can be runned manually via SSH so it can’t be the problem here.

Is there anything I am missing? Any suggestions?