32 lines
1.1 KiB
Markdown
32 lines
1.1 KiB
Markdown
Create user automation as system user
|
|
Get pub ssh key from hass instance and put here `/home/automation/.ssh/authorized_keys`
|
|
|
|
/etc/sudoers.d/hass-automation
|
|
```
|
|
automation ALL=NOPASSWD:/usr/sbin/poweroff
|
|
automation ALL=NOPASSWD:/usr/sbin/reboot
|
|
```
|
|
|
|
|
|
/etc/polkit-1/rules.d/00-hass.rules
|
|
```
|
|
polkit.addRule(function(action, subject) {
|
|
if (action.id == "org.freedesktop.login1.suspend-multiple-sessions" && subject.user == "automation"){
|
|
return polkit.Result.YES;
|
|
}
|
|
});
|
|
|
|
|
|
polkit.addRule(function(action, subject) {
|
|
if (action.id == "org.freedesktop.login1.hibernate-multiple-sessions" && subject.user == "automation"){
|
|
return polkit.Result.YES;
|
|
}
|
|
});
|
|
|
|
```
|
|
|
|
/srv/HomeAssistant/data/shellcmd.yaml
|
|
```
|
|
<SystemName>_stby: "timeout 5s ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no automation@<ip or hostname> '/usr/bin/dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 'org.freedesktop.login1.Manager.Suspend' boolean:true'"
|
|
<SystemName>_off: "timeout 5s ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no automation@<ip or hostname> 'sudo /usr/sbin/poweroff'"
|
|
``` |