Skip to content

Commit

Permalink
Create tasmota_2_vz.py
Browse files Browse the repository at this point in the history
a little script that runs as cronjob every minute.
it read the power measure from a tasmota flashed Sonoff POWR316D
every 20 sec and repeats that value 20 times, to reduce network load
this value is appended to the soyo.log which also exports the data from zeroinput script.
  • Loading branch information
E-t0m committed Mar 22, 2023
1 parent 9309e73 commit e0968c9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tasmota_2_vz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import requests
from time import time, sleep

debug = False

url = 'http://111.222.333.444/cm?cmnd=status%2010'
z = 0
for i in range(0,3):
resp = requests.get(url=url)
data = resp.json()

if debug: print('read')

try: power = data['StatusSNS']['ENERGY']['Power']
except:
if debug: print('sleep')
sleep(20)
pass
else:
for j in range(0,20):
with open('/tmp/vz/soyo.log','a') as fo:
fo.write('%i: klima_p = %i\n' % ( time(), power ) )
if debug:
print('%i: klima_p = %i\n' % ( time(), power ) )
z += 1
print(i,j,z)
sleep(1)

exit(0)

0 comments on commit e0968c9

Please sign in to comment.