tasmota-charge telegraf

This commit is contained in:
mwiegand 2021-12-16 00:29:52 +01:00
parent 3c09b3a984
commit 7663d3fcce
3 changed files with 48 additions and 1 deletions
bundles/tasmota-charge

View file

@ -0,0 +1,18 @@
#!/bin/bash
PLUG_IP=${plug_ip}
PLUG_IS=$(curl -s "http://$PLUG_IP/cm?cmnd=Power" | jq -r .POWER)
if [[ $PLUG_IS = ON ]]
then
STATE=1
elif [[ $PLUG_IS = OFF ]]
then
STATE=0
else
echo "unknown state: '$PLUG_IS'"
exit 1
fi
echo "tasmota_charge,host=${node.name} state=$STATE $(date --utc +%s%N)"

View file

@ -11,4 +11,12 @@ files = {
'max': node.metadata.get('tasmota-charge/plug/max'),
}
},
'/usr/local/share/icinga/plugins/tasmota_charge': {
'content_type': 'mako',
'source': 'telegraf-plugin',
'mode': '0755',
'context': {
'plug_ip': node.metadata.get('tasmota-charge/plug/ip'),
}
},
}

View file

@ -9,5 +9,26 @@ defaults = {
'command': f'/usr/bin/sudo -u tasmota-charge /opt/tasmota-charge',
'when': 'minutely',
},
}
},
}
@metadata_reactor.provides(
'telegraf/config/inpus/exec',
)
def telegraf(metadata):
return {
'telegraf': {
'config': {
'inputs': {
'exec': {
repo.libs.hashable.hashable({
'commands': ["/usr/local/share/icinga/plugins/tasmota_charge"],
'name_override': "tasmota_charge",
'data_format': "influx",
}),
},
},
},
},
}