darkmode
New Member
oof. That was both easier and harder than I expected.
I just installed InfluxDB into HA. This makes it easy to pass data from HA to InfluxDB, but makes it harder to get data directly into the InfluxDB instance.
With the help of ChatGPT, I created a bash script to parseand then pass the info for each optimizer to HA using the REST API (which can be called from curl).Code:/mnt/ffs/data/daqs
Once in HA, I can pass the info to InfluxDB.
This worked!
But it was made more complicated because:
- Apparently this thing runs BusyBox and doesn't have a complete version of grep, so the initial parsing method didn't work.
- For... reasons... crond is using a file that is NOT where crontab looks. So crontab -e doesn't edit the right thing.
- I created HA sensors for each optimizer, that then have attributes for power, voltage, etc. Although this is cleaner, I haven't figured out how to get InfluxDB to understand this (yet).
Yes, normal crontab editing will not work. Simply edit the crontab located at /mnt/ffs/etc/crontab.
Here is the script named data-to-influxdb.sh that I use to push data to my standalone InfluxDB instance:
Bash:
#!/bin/sh
INFLUXIP="192.168.0.200:8086"
ORG="homelab"
BUCKET="tigo-pv-stats"
TOKEN="MySecretToken"
DATA=$(getinfo --dir /mnt/ffs/data/daqs --prefix daqs. | tr '\n' ',')
NEWDATA=$(echo $DATA | cat | tail -c +34 | head -c -9 | sed 's/=\,/=0\,/g' | sed 's/\,TimeStamp=/\ /g')
NEWDATA=$NEWDATA"000000000"
curl -XPOST "http://$INFLUXIP/api/v2/write?org=$ORG&bucket=$BUCKET" --header "Authorization: Token $TOKEN" --data-raw "Tigo-ACC $NEWDATA"
My crontab has this entry:
Code:
* * * * * /mnt/ffs/bin/data-to-influxdb.sh
Hope this helps.
Last edited: