I’m trying to control the WiFi of my OpenWRT router from Home Assistant using a command_line switch. The goal is to enable or disable a wireless interface (wifinet2). I’ve set up the switch using the new-style command_line configuration (not under switch: directly).
The problem:
All SSH commands (command_on, command_off, and command_state) work perfectly when I run them manually from the Home Assistant terminal (SSH add-on or shell).
In Home Assistant, the switch shows up in the UI, but toggling it doesn’t seem to do anything.
The state is never updated correctly — it always shows as “off”, regardless of the actual WiFi status.
The SSH addon is another container with its own environment, so you might have set up SSH there, but when you run the command line as a script in HA, then it is run in the HA container with another environment, where SSH is not configured.
Thank you for pointing me in the right direction! The issue was indeed related to SSH environment isolation between HA’s container and the SSH add-on. Here’s how I solved it for future reference: