- Joined
- Jan 15, 2020
- Messages
- 1,695
- Reaction score
- 1,607
Hey sorry that I just come back to you now, you forgot the @ in front of my name for the tag to work.hi elysics so I registered the nous a1t and set it up in reef-pi. Thanks a lot for this. I assume that the a1t are only for switching and cannot use the power consumed in the ree-pi?
yes it is possible.
I was going to change the code of the tasmota driver directly, but laziness won out and I used the file driver for that too. Didn't want to confuse you with even more code during setup
Again, this is only a lazy solution, not perfect code.
First, on your pi, install jq:
Code:
sudo apt-get install jq
Then, in your home folder, or somewhere else, create a folder just for the currents to keep everything neat, I chose /home/pi/currents, and then go into that folder:
Code:
mkdir /home/pi/currents
cd /home/pi/currents
Then create a script currscript.sh:
Code:
echo "curl -s http://\$1/cm?cmnd=STATUS+10 | jq '.StatusSNS.ENERGY.Current'>/home/pi/currents/snsCurr\$1">/home/pi/currents/currscript.sh
sudo chmod +x currscript.sh
Then create another script requestCurrs.sh that calls the first one for all the ips of your plugs, my ips are examples:
Code:
echo "/home/pi/currents/currscript.sh 192.168.178.25
/home/pi/currents/currscript.sh 192.168.178.26
/home/pi/currents/currscript.sh 192.168.178.27" >/home/pi/currents/requestCurrs.sh
sudo chmod +x requestCurrs.sh
Then, again, schedule the last script to run regularly, I chose every 20 seconds, but you can do every minute, it takes a couple seconds to run, type "crontab - e"
And add the following line at the end:
Code:
* * * * * /bin/bash -c ' for i in {1..3}; do /home/pi/currents/requestCurrs.sh; sleep 20; done'
Then you should have text files in the currents folder named something like snsCurr192.168.178.25 or whatever the ip address of that particular plug is, that text file contains the current measurement.
Go into reef pi, Configuration->Drivers
And add a file-analog driver per plug and and input the path to the corresponding file like /home/pi/currents/snsCurr192.168.178.25
Then configuration->connectors->analog inputs and add a input per newly created driver, pin 0
Then go into the pH menu and add a pH Probe per newly created connector, check frequency 20 seconds or whatever period you chose, chart minimum 0, chart maximum whatever makes sense for your device, chart unit you can use "A" for Ampere if you want.
Then you can add those "pH probes" to your dashboard and/or do logic with them or whatever you want.
And now my fingers are sore from typing this on a phone, I hope there are no typos in the code
Edit: if you don't want current but actually power that works too, use
Code:
.StatusSNS.ENERGY.Power
Or
Code:
.StatusSNS.ENERGY.ApparentPower
In the first script instead
Edit2: fixed the crontab code
Last edited: