Hi
I want to reboot my Asuswrt router when the 2.4hz radio fails. I’ve got the Asuswrt integration working and its tracking devices using 2.4hz radio, so the automation is tracking a entity which is using that radio
I’ve also install the SSH keys so HA can SSH into the remote router without a password
I’ve created a few automation conditions but cannot get the action correct in the GUI or even the YML editor
Here is the automation.yaml file
- id: '1673906360178'
alias: Reboot Router
description: ''
trigger:
- platform: state
entity_id:
- device_tracker.garage_door
from: home
to: away
condition: []
action: []
- service: /config/reboot.yaml
I then started to create a shell_command script here
reboot_router: ssh -l admin 192.168.0.1 "reboot"
Then the main reboot.yaml file
reboot_router:
alias: Reboot Router Script
sequence:
- service: shell_command.reboot_router
But I’m struggling to put it all together to create an automation. Can someone help please ?
Thanks
tmjpugh
(Tmjpugh)
January 18, 2023, 4:38am
2
Read shell command docs
Your automation should call the shell command service like below
- id: '1673906360178'
alias: Reboot Router
description: ''
trigger:
- platform: state
entity_id:
- device_tracker.garage_door
from: home
to: away
condition: []
action: []
- service: shell_command.reboot_router
You should add shell command section in your config that defines “reboot_router” as the command you desire like
shell_command:
reboot_router: ssh -l admin 192.168.0.1 "reboot"
Not certain above is 100% so verify with docs
EdwardTFN
(Edward Firmo)
January 18, 2023, 4:44am
3
By the way, there is another implementation of an ASUS router integration, by @Vaskivskyi , which already have a restart button and solve this for you.
1 Like
Ok I’ve changed
The automation.yml file
- id: '1673906360178'
alias: Reboot Router
description: ''
trigger:
- platform: state
entity_id:
- device_tracker_garage_door
from: home
to: away
condition: []
action:
- service: shell_command.reboot_router
Then the config.yml file
shell_command:
reboot_router: ssh -i /root/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] 'reboot'
I now get this error message in the logs
Error running command: ssh -i /root/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] 'reboot'
, return code: 255
tmjpugh
(Tmjpugh)
January 18, 2023, 1:28pm
5
Have you ssh between these to server before?
Server is not in known host file so blocking connection
If you manually connect it may ask you “do you want to add” but if not you may need to manually add.
Docker container and host are not same device from ssh perspective so even if ssh from host you still need to do from container
1 Like
I setup a SSH cert and it works from cli without password
Could the problem the client side of the SSH request is from a container not the host itself ?
Just checked the CLI
OS Version: Home Assistant OS 9.4
Home Assistant Core: 2023.1.5
Do you seriously want such an automation ?, … reboot your router every time the
device_tracker.garage_door in ha, turns to " away" ?
Hi,
Did all this work out for you? Trying to do the same on my HA currently