<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Integracja chmury solarman z domoticzem - Domoticz				            </title>
            <link>https://www.smartnydom.pl/forum/domoticz/integracja-chmury-solarman-z-domoticzem/</link>
            <description>Discussion Board</description>
            <language>pl-PL</language>
            <lastBuildDate>Sat, 08 Aug 2026 07:13:00 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Integracja chmury solarman z domoticzem</title>
                        <link>https://www.smartnydom.pl/forum/domoticz/integracja-chmury-solarman-z-domoticzem/#post-33134</link>
                        <pubDate>Sun, 23 Jun 2024 18:55:00 +0000</pubDate>
                        <description><![CDATA[Może komuś się przyda
Aby zintegrować dowolny falownik który współpracuje z chmurą globalapi.solarmanpv.com trzeba napisać na adres customerservice@solarmanpv.com prośbę o odblokowanie API...]]></description>
                        <content:encoded><![CDATA[<p>Może komuś się przyda</p>
<p>Aby zintegrować dowolny falownik który współpracuje z chmurą globalapi.solarmanpv.com trzeba napisać na adres customerservice@solarmanpv.com prośbę o odblokowanie API</p>
<p>W odpowiedzi otrzymamy regulamin. Należy odpisać, że przeczytaliśmy i że się zgadzamy.</p>
<p>W kolejnej odpowiedzi otrzymamy :<br />API ID：xxxxxxxxxxxx<br />API Secret: xxxxxxxxxxxxxxxxxxx<br />Dane te będziemy potrzebować do naszego skryptu</p>
<p>W domoticzu tworzymy czujnik "Electric(Instant+Counter) i w skrypcie podajemy jego IDX<br />Oto skrypt xxx.py który umieszczamy w katalogu /domoticz/scripts/python</p>
<p>Nadajemy skryptowi prawa wykonywalności oraz dodajemy do Crontab wykonanie skryptu np. co 5 minut</p>
<pre contenteditable="false">#!/usr/bin/env python3

import http.client, urllib.request, json, hashlib
from datetime import datetime

#Trannergy account details
apiSite   = "globalapi.solarmanpv.com"
appID     = "xxxxxxxxxxx"		#Change to your own appID, to be provided from Trannergy/Solarman
appSecret = "xxxxxxxxxx"		#Change to your own appSecret, to be provided from Trannergy/Solarman
email     = "xxxxxxxxxxx"		#Change to your own account name/mail address
password  = b"xxxxxxxxxxxxx"		#Change password to your own, maintain the b in front of the password as password need to be binary

conn      = http.client.HTTPSConnection(apiSite)
password = hashlib.sha256(password).hexdigest()

#domoticz settings
domoticz_host           = "xxxxxxxxx" #ip adress of the domoticz host
domoticz_port           = "xxxx"
domoticz_url            = "json.htm"
domoticz_ActualPower    = "xxx" #idx of new device

#Request access token, manaul chapter/routine 2.1
payload = json.dumps({
  "appSecret": appSecret,
  "email": email,
  "password": password
})
headers = {
  'Content-Type': 'application/json'
}
conn.request("POST", "/account/v1.0/token?appId="+appID+"&amp;language=en", payload, headers)
res = conn.getresponse()
data = json.loads(res.read())
accesstoken = data
print("Accesstoken :" +accesstoken)

#Request current power + lastupdate time + stationID, manual chapter/routine 4.4
payload = json.dumps({
  "page": 1,
  "size": 20
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'bearer '+accesstoken
}
conn.request("POST", "/station/v1.0/list?language=en", payload, headers)
res = conn.getresponse()
data = json.loads(res.read())
stationID = str(data)
currentpower = str(data)
lastupdatetime = int(data)
lastupdatetime = str(datetime.fromtimestamp(lastupdatetime))
print("Current Power :"+currentpower+"W")
print("Last update time :"+lastupdatetime)
print("StationID :"+stationID)

#Request deviceID + deviceSN, manual chapter/routine 4.2
payload = json.dumps({
  "deviceType": "INVERTER",
  "page": 1,
  "size": 10,
  "stationId": stationID
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'bearer '+accesstoken
}
conn.request("POST", "/station/v1.0/device?language=en", payload, headers)
res = conn.getresponse()
data = json.loads(res.read())
deviceID = str(data)
deviceSN = str(data)
print('Device serial : '+deviceSN)
print('Device ID : '+deviceID)

#Total generated power, manual chapter/routine 3.3
payload = json.dumps({
  "deviceSn": deviceSN,
  "deviceId": deviceID
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'bearer '+accesstoken
}
conn.request("POST", "/device/v1.0/currentData?language=en", payload, headers)
res = conn.getresponse()
data = json.loads(res.read())
multiply='1000.0'
totalgenpower = float(data) * float(multiply)
totalgenpower = str(totalgenpower)
print("Total generated power: " +totalgenpower+"W")

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&amp;param=udevice&amp;idx=" + domoticz_ActualPower+ "&amp;nvalue=0&amp;svalue=" + currentpower+ ";" + totalgenpower)
urllib.request.urlopen(url)
print(url)
</pre>]]></content:encoded>
						                            <category domain="https://www.smartnydom.pl/forum/domoticz/">Domoticz</category>                        <dc:creator>kniazio</dc:creator>
                        <guid isPermaLink="true">https://www.smartnydom.pl/forum/domoticz/integracja-chmury-solarman-z-domoticzem/#post-33134</guid>
                    </item>
							        </channel>
        </rss>
		
<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 48/55 objects using Memcached
Page Caching using Memcached (Requested URI contains query) 
Database Caching 8/34 queries in 0.021 seconds using Memcached

Served from: www.smartnydom.pl @ 2026-08-08 09:13:00 by W3 Total Cache
-->