tasmota-charge
This commit is contained in:
parent
41430ebc2f
commit
3c09b3a984
6 changed files with 87 additions and 0 deletions
14
bundles/tasmota-charge/README.md
Normal file
14
bundles/tasmota-charge/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Phone
|
||||
|
||||
- install termux from Play Store
|
||||
- install termux::api from Play Store
|
||||
- open termux
|
||||
- run `pkg install termux-api openssh`
|
||||
- run `passwd` and set a password
|
||||
- run `whoami` to get the username
|
||||
- run `sshd` to start ssh server
|
||||
- acquire wakelock for the termux session in notifications
|
||||
|
||||
# Server
|
||||
|
||||
- you can run something like `su - tasmota-charge -c 'ssh-copy-id -p 8022 u0_q194@10.0.0.166'`
|
27
bundles/tasmota-charge/files/tasmota-charge
Normal file
27
bundles/tasmota-charge/files/tasmota-charge
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
PHONE_IP=${phone_ip}
|
||||
PHONE_USER=${phone_user}
|
||||
PLUG_IP=${plug_ip}
|
||||
MIN=${min}
|
||||
MAX=${max}
|
||||
|
||||
AKKU=$(ssh -p 8022 $PHONE_USER@$PHONE_IP termux-battery-status | jq -r .percentage)
|
||||
echo "akku is at $AKKU%"
|
||||
|
||||
PLUG_IS=$(curl -s "http://$PLUG_IP/cm?cmnd=Power" | jq -r .POWER)
|
||||
echo "plug is $PLUG_IS"
|
||||
|
||||
if [[ $AKKU < $MIN ]] && [[ $PLUG_IS = OFF ]]
|
||||
then
|
||||
TURN_PLUG=ON
|
||||
elif [[ $AKKU > $MAX ]] && [[ $PLUG_IS = ON ]]
|
||||
then
|
||||
TURN_PLUG=OFF
|
||||
else
|
||||
echo "nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "turning plug $TURN_PLUG"
|
||||
curl -s "http://$PLUG_IP/cm?cmnd=Power%20$TURN_PLUG"
|
14
bundles/tasmota-charge/items.py
Normal file
14
bundles/tasmota-charge/items.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
files = {
|
||||
'/opt/tasmota-charge': {
|
||||
'owner': 'tasmota-charge',
|
||||
'mode': '0550',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'phone_ip': node.metadata.get('tasmota-charge/phone/ip'),
|
||||
'phone_user': node.metadata.get('tasmota-charge/phone/user'),
|
||||
'plug_ip': node.metadata.get('tasmota-charge/plug/ip'),
|
||||
'min': node.metadata.get('tasmota-charge/plug/min'),
|
||||
'max': node.metadata.get('tasmota-charge/plug/max'),
|
||||
}
|
||||
},
|
||||
}
|
13
bundles/tasmota-charge/metadata.py
Normal file
13
bundles/tasmota-charge/metadata.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
defaults = {
|
||||
'users': {
|
||||
'tasmota-charge': {
|
||||
'home': '/home/tasmota-charge',
|
||||
},
|
||||
},
|
||||
'systemd-timers': {
|
||||
'tasmota-charge': {
|
||||
'command': f'/usr/bin/sudo -u tasmota-charge /opt/tasmota-charge',
|
||||
'when': 'minutely',
|
||||
},
|
||||
}
|
||||
}
|
|
@ -8,6 +8,12 @@ for name, config in node.metadata.get('users').items():
|
|||
'mode': config.get('home_mode', '700'),
|
||||
}
|
||||
|
||||
directories[f"{config['home']}/.ssh"] = {
|
||||
'owner': config.get('home_owner', name),
|
||||
'group': config.get('home_group', name),
|
||||
'mode': '0700',
|
||||
}
|
||||
|
||||
files[f"{config['home']}/.ssh/id_{config['keytype']}"] = {
|
||||
'content': config['privkey'] + '\n',
|
||||
'owner': name,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
'wireguard',
|
||||
'zfs',
|
||||
'crystal',
|
||||
'tasmota-charge',
|
||||
],
|
||||
'metadata': {
|
||||
'id': 'af96709e-b13f-4965-a588-ef2cd476437a',
|
||||
|
@ -84,6 +85,18 @@
|
|||
'unsortable': 'SofortUpload/Unsortable',
|
||||
},
|
||||
},
|
||||
'tasmota-charge': {
|
||||
'phone': {
|
||||
'ip': '10.0.0.166',
|
||||
'user': 'u0_q194',
|
||||
'password': 'november',
|
||||
},
|
||||
'plug': {
|
||||
'ip': '10.0.2.115',
|
||||
'min': 45,
|
||||
'max': 70,
|
||||
},
|
||||
},
|
||||
'vm': {
|
||||
'cores': 2,
|
||||
'ram': 16192,
|
||||
|
|
Loading…
Reference in a new issue