The number you get is the first number from your device-id
The bash-script is ereasing all others characters then the real result
And if you dont get the correct result, all the rest will be fu*ked up
You have to find out why you cant connect to your plug with plugpower.py
Are you using python or python3 ?
Can you ping the plug from the terminal you try the script from ?
From start the real result is
pi@raspberrypi:~/Downloads/powermonitor $ python plugpower.py
Polling Device 46268374cXXXXXXXX at 192.168.0.XXX
Dictionary {u'devId': u'46268374cXXXXXXX', u'dps': {u'24': 17521, u'25': 1190, u'20': 2312, u'21': 1, u'22': 635, u'23': 30333, u'19': 0, u'18': 0, u'1': False, u'9': 0}}
Switch On: False
First line in bash-script is deleting first row Polling Device 46268374cXXXXXXXX at 192.168.0.XXX
echo -e “$(sed ‘1d’ /home/pi/script/power/plug.log)\n” > plug.log
Next line is deleting 139 first characters Dictionary {u’devId’: u’46268374cXXXX’, u’dps’: {u’24’: 17521, u’25’: 1190, u’20’: 2297, u’21’: 1, u’22’: 635, u’23’: 30
333, u’19’:
sed ‘s/^.{139}//’ plug.log > plug1.log
Next line is break all numbers to rows
0
18
0
1
9
0
grep -o -E ‘[0-9]+’ plug1.log
Next line is cut out the single row with the real result
0
sed -n ‘1p’ plug.log
Next line is a math-calculator to multipli the result with 0,1
perl -pe ‘s/\b(\d+.)?\d+\b/$&*0.1/ge’ plug1.log
if i change the ip on my plug and try polling, it will result 4626837.4 and its the first number from device-id multipli with 0.1 ( 46268374 *0,1 = 4626837.4 )