If you want to test if this script will work before you install it, copy this link in your browser : http://*your local SAJ URL*/status/status.php
If you get a webpage with a list of numbers, you are good to go.
For this script you need to have the python requests library installed.
Make a dummy energy device and remember the IDX. Give your SAJ solarinverter a static IP in your router. replace the *** in the script with your values.
Code: Select all
import requests
from requests.auth import HTTPBasicAuth
DOMOTICZ = 'http://***' #input your domoticz IP here
IDX ='***' #input your energy idx here
SAJ = 'http://***' #input your local SAJ IP here
SAJURL = SAJ + '/status/status.php'
file = requests.get(SAJURL, auth=HTTPBasicAuth('***', '***')) #input your login here between the ' '
print(file.status_code)
text = file.text
list = text.split(',')
POWER = list[23]
ENERGY = int(list[1])
ENERGYCALC = str(ENERGY * 10)
requests.get(DOMOTICZ+'/json.htm?type=command¶m=udevice&idx='+IDX+'&nvalue=0&svalue='+POWER+';'+ENERGYCALC)