Compare commits
No commits in common. "bc898c800912f066eba72e8310a88d0bf0c34265" and "bb862ed6ec77119319dd5503982e556d4d178f11" have entirely different histories.
bc898c8009
...
bb862ed6ec
4 changed files with 0 additions and 111 deletions
|
@ -1,35 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# gpiochip number + pin number
|
||||
gpio=$(expr 458 + 3)
|
||||
|
||||
# prepare
|
||||
if ! [[ -e "/sys/class/gpio/gpio$gpio" ]]; then
|
||||
echo $gpio > "/sys/class/gpio/export"
|
||||
fi
|
||||
echo in > "/sys/class/gpio/gpio$gpio/direction"
|
||||
|
||||
# loop
|
||||
previous_state=false
|
||||
while sleep 0.001; do
|
||||
state=$(cat "/sys/class/gpio/gpio$gpio/value")
|
||||
if ! [[ "$state" = "$previous_state" ]] && [[ "$state" = 0 ]]
|
||||
then
|
||||
if ! [ -z $previous_impulse ] # skip first iteration
|
||||
then
|
||||
delay=$(expr $(date --utc +%s%N) - $previous_impulse)
|
||||
impulse_per_hour=$(expr 3600000000000 / $delay)
|
||||
watt=$(expr $impulse_per_hour / $(expr 2000 / 1000))
|
||||
echo "$watt watts"
|
||||
curl "https://${influxdb_domain}/api/v2/write?org=${influxdb_org}&bucket=${influxdb_bucket}&precision=ns" ${'\\'}
|
||||
-X POST ${'\\'}
|
||||
--header "Authorization: Token ${influxdb_token}" ${'\\'}
|
||||
--header "Content-Type: text/plain; charset=utf-8" ${'\\'}
|
||||
--header "Accept: application/json" ${'\\'}
|
||||
--data-binary "powermeter,host=${node_name} watts=$watt" ${'\\'}
|
||||
2&> /dev/null &
|
||||
fi
|
||||
previous_impulse=$(date --utc +%s%N)
|
||||
fi
|
||||
previous_state=$state
|
||||
done
|
|
@ -1,28 +0,0 @@
|
|||
influxdb_metadata = repo.get_node(node.metadata.get('stromzaehler/influxdb_node')).metadata.get('influxdb')
|
||||
|
||||
files = {
|
||||
'/opt/stromzaehler': {
|
||||
'content_type': 'mako',
|
||||
'mode': '550',
|
||||
'context': {
|
||||
'node_name': node.name,
|
||||
'influxdb_domain': influxdb_metadata['hostname'],
|
||||
'influxdb_bucket': influxdb_metadata['bucket'],
|
||||
'influxdb_org': influxdb_metadata['org'],
|
||||
'influxdb_token': influxdb_metadata['admin_token'],
|
||||
},
|
||||
'triggers': [
|
||||
'svc_systemd:stromzaehler:restart'
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
svc_systemd = {
|
||||
'stromzaehler': {
|
||||
# 'enabled': False,
|
||||
# 'running': False,
|
||||
'needs': [
|
||||
'file:/opt/stromzaehler',
|
||||
],
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'packages': {
|
||||
'curl': {},
|
||||
'gpiod': {},
|
||||
},
|
||||
},
|
||||
'systemd': {
|
||||
'units': {
|
||||
'stromzaehler.service': {
|
||||
'Unit': {
|
||||
'Description': 'stromzaehler',
|
||||
'After': 'network.target',
|
||||
},
|
||||
'Service': {
|
||||
'ExecStart': '/opt/stromzaehler',
|
||||
},
|
||||
'Install': {
|
||||
'WantedBy': {'multi-user.target'},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
{
|
||||
'hostname': '10.0.0.15',
|
||||
'groups': [
|
||||
'debian-11',
|
||||
'raspberry-pi',
|
||||
'monitored',
|
||||
],
|
||||
'bundles': [
|
||||
'stromzaehler',
|
||||
],
|
||||
'metadata': {
|
||||
'id': 'dd521b8a-dc03-43f5-b29f-068f948ba3b8',
|
||||
'network': {
|
||||
'internal': {
|
||||
'interface': 'eth0',
|
||||
'ipv4': '10.0.0.15/24',
|
||||
'gateway4': '10.0.0.1',
|
||||
},
|
||||
},
|
||||
'stromzaehler': {
|
||||
'influxdb_node': 'home.server',
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue