Command_switch show in group

I have added a command_switch with following

platform: command_line
switches:
tasker_say:
friendly_name: “Tasker Say”
command_on: python “[python_scripts/on.py]”
command_off: python “[python_scripts/off.py]”

I wish to show this in a group so I added

view: yes
entities:

  • group.people
  • group.date_and_time
  • group.weather_overview
  • group.sun
  • group.daily_forecast
  • switch.tasker_say

but I can’t for the life of me work out how to get the switch to show so I can test my tasker action

Put it in it’s own group and add that group to the above group, then it should appear properly

Sorry I posted the wrong question above.

I should be able to display the switch on its own without the need for it to be in a group right? I can do so with my broadlink switches. All I want to do is test that the switch toggle works as expected then I will add it to part of a scene.

It depends how you have setup your frontend, if you have NOT set a default view up it will already be in your frontend view, if you have then it won’t appear until you add it to a group.

Hi this is from my default_view.yaml within groups.

I want to send a trigger to my andriod tablet to start spotify app.

  1. I created a python script
  2. created a command_switch pointing to those py scripts
  3. added switch to default_view group to display switch

Switch fails to show :frowning:

This is from the log
reproduce_state: Unable to find entity switch.tasker_say

Check in the states view that the entity id is correct.

In states I can’t find my entity so my command_switch is incorrect.

switch: !include_dir_merge_list switches
/config/switches/command.yaml looks like this

platform: command_switch
switches:
tasker_say:
friendly_name: “Tasker Say”
oncmd: python “[/python_scripts/on.py]”
offcmd: python “[/python_scripts/off.py]”

Sorry I haven’t worked out how to post code properly yet.

There’s no such platform as command_switch. Do you mean command_line?

I have tried it both ways, I was following this

Either there’s a typo in that guide, or the platform has been changed/deprecated.

I suspect you need to use command_line.

I tried with command_line but still I have no entity

1 - have you restarted HA since changing the file?

2 - can you post the relevant config in code blocks so we can check your formatting?

Yes I restart after every change to see if it has worked. I decovered i created my .py scripts with a capitol letter so this could be the issue I have made changes and will let you know.

How do I post in code blocks I haven’t been able do it successfully yet.

platform: command_line
switches:
  tasker_say:
    friendly_name: Tasker Say
    command_on: python /python_scripts/on.py
    command_off: python /python_scripts/off.py

worked out how to post code block

… And that doesn’t appear in your entity list?

Any errors in the log?

Please post what’s above and below that in your configuration, and where it is (directly in configuration.yaml, linked file, etc)?

configuration.yaml

automation: !include_dir_merge_list automation
script: !include scripts.yaml
device_tracker: !include device_tracker.yaml
sensor: !include_dir_merge_list sensors
binary_sensor: !include_dir_merge_list binary_sensors
zone: !include zones.yaml
camera: !include_dir_merge_list cameras
switch: !include_dir_merge_list switches
media_player: !include_dir_merge_list media_players
scene: !include_dir_merge_list scenes
light: !include_dir_merge_list lights
python_script: !include_dir_named python_scripts

/config/switches/command.yaml

platform: command_line
switches:
  tasker_say:
    friendly_name: Tasker Say
    command_on: python /python_scripts/on.py
    command_off: python /python_scripts/off.py

/config/groups/default_view.yaml

view: yes
entities:
 - group.people
 - group.date_and_time
 - group.weather_overview
 - group.sun
 - group.daily_forecast
 - switch.tasker_say

At the least these will need the full path to the .py files and you may need the full path to python as well.

I’m using hass.io what should my paths look like?

with my python_scripts folder is sitting in the config/

I would guess at /config/python_scripts/on.py

python maybe in the path variable in which case it should be OK, if not I don’t know.

The following works for me using AutoRemote

- platform: command_line
  switches:
    tasker_say:
      command_on:  python3 "/config/python_scripts/SayOn.py"
      command_off: python3 "/config/python_scripts/SayOff.py"

This worked to add the switch :slight_smile: the guide I was following had old code.

Now I tried to call the service python script and got the following error

Error executing script: import not found
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/components/python_script.py”, line 166, in execute
exec(compiled.code, restricted_globals, local)
File “off.py”, line 1, in
ImportError: import not found

from requests import get
requests.get('[myurlishere]')