Giter Club home page Giter Club logo

blazejosp / huawei-sun2000-api-cli Goto Github PK

View Code? Open in Web Editor NEW
106.0 17.0 15.0 14.07 MB

Huawei SUN2000 compatible devices which working with Huawei Cloud Service command line bash API for monitoring or download data from their FusionSolarApp API

Home Page: https://www.buymeacoffee.com/blazejosP

License: GNU General Public License v3.0

Shell 100.00%
huawei solar solar-energy api-client inverter openapi-account huawei-fusionsolar sun2000 api-gateway client shell bash

huawei-sun2000-api-cli's Introduction

Huawei sun2000 API CLI

GitHub license GitHub issues Language GitHub repo size GitHub forks GitHub Repo stars

If you found this software usefully and do like to say thank you!

Nothing actually

Linux Command line tool for acess Huawei FusionSolarApp API

Huawei sun2000 series (here list of the devices https://solar.huawei.com/eu) should work with all devices which are working in their cloud service. This is command line bash API for view/download data from their FusionSolarApp web service without use of their webpage. To use this tool you may need kioskmode link as a minimum. But to fully use this tool you need an acount in their service and then request developer account. That all means that you need Huawei sun2000 https://solar.huawei.com/eu/products series PV inverter configured already with their cloud service or someone who give you acess to cloud service related with his Huawei device.

To use this script you must have as a minimum kioskmode link given to you by someone else who has Huawei account. But to fully use this software you need account on Huawei FusionSolar https://eu5.fusionsolar.huawei.com and developer privilege.

Contact service team at [email protected] to create an openAPI account for your plant. Inside email like this:

Email Template

Hi, I hereby request an openAPI user account to access the data from my inverter(s) through the new #FusionSolar API:

System name: <--here data--> 

Username: <--here data--> 

Plant Name: <--here data--> 

SN Inverter: <--here data-->

Device Sun2000-(from 3KTL to 100KTL meaby also others)-M0/M1

Confirmed by user of this software devices which are working for certain (devices not marked should work because are implemented but we haven't any confirmation to be certain)

  • String inverter
    • SUN2000-5KTL-M0
    • SUN2000-30KTL-M3
  • Dongle
    • SDongleA-05
  • Residential inverter
    • SUN2000-4.6KTL-L1
  • Smart Logger
  • EMI
  • Meter (Grid meter)
  • Power Sensor
  • Battery (LG batteries)
  • Battery (Huawei Luna2000)

Device itself must be equipped with Smart Dongle existing two types:

Smart Dongle-4G (sends data through cellular network -> to internet -> and then stright to cloud service)

SmartDongle-WLAN-FE (sends data with use of user lan or wlan -> through user getway -> internet -> to cloud service)

Whatever dongle is in use there must be an connection to internet if not cloud service simple don't recieve new data.

Huawei-sun2000

Installation

This is tool for login and get data from Huawei FusionSolar https://eu5.fusionsolar.huawei.com This tool use official FusionSolar API described here https://forum.huawei.com/enterprise/en/communicate-with-fusionsolar-through-an-openapi-account/thread/591478-100027 by manufacturer. Data from official API are instantous or every 5 mintes, hour, day, monthly, yearly.

You must have installed on your linux tools like curl, jq, httpie, grep, mosquitto_pub on debian and similar systems. They are necessary for working of this bash scripts. On Debian like system you can download them with:

sudo apt-get install curl

sudo apt-get install jq

sudo apt-get install grep

sudo apt-get install httpie

sudo apt-get install mosquitto-clients (if MQTT sending option will be used)

sudo apt-get install dialog (if TUI will be used)

or at once all with

sudo apt-get install curl jq grep httpie dialog mosquitto-clients

On other linux distributions check used package system but that are standard linux command line tools so should be avaiable without problems if are not installed already.

Configuration&Usage

config.conf - this file is needed by both fusionsolarapp.sh & fusionsolarapp_interface.sh and have inside stored your Usernames & Passwords and also links to kioskmodes which you have or have acess to them. You must edit this file first to made this software working. Now you can use this software even without huawei account if you can paste kioskmode given to you by someone else.

fusionsolarapp.sh - which is using official Huawei API called OpenAPI by Huawei. Now this script can pull and show on the screen data Real-time(actually), every 5min , daily, monthly, yearly for Plants (which may include many inverters+any other devices data together) and Individual Devices (like every one inverter, battery etc.) This script is now under development and for now can only grab all the data from your devices and show them on screen & if you choose option save to file. In not so long time will be able also send this data to InfluxDB(grafana), Domoticz, MQTT. This script need individual configuration inside if you need data tailored to your needs. How do this is described here #12

Then inside you can extract this data:

  • Plant data
    • realtime plant performace
    • actually and historical plant performace resolution every 5 minutes inside day
    • actually and historical plant performace resolution 30 days
    • actually and historical plant performace resolution 12 month
    • actually and historical plant performace resolution all years
  • individual device data
    • realtime device performace
    • actually and historical data device performance resolution every 5 minutes inside day
    • actually and historical data device performace resolution 30 days
    • actually and historical data device performace resolution 12 month
    • actually and historical data device performace resolution all years

FusionSolarApp

fusionsolarapp_interface.sh - this is the same program but with TUI graphical interface you must install additionally dialog. As for now you can login inside software will ask you about Login and Password if this data are not provided by config.conf. And check this properties inside checked below.

Then inside you can check:

  • Plant data
    • realtime plant performace
    • actually and historical plant performace resolution every 5 minutes inside day
    • actually and historical plant performace resolution 30 days
    • actually and historical plant performace resolution 12 month
    • actually and historical plant performace resolution all years
  • individual device data
    • realtime device performace
    • actually and historical data device performance resolution every 5 minutes inside day
    • actually and historical data device performace resolution 30 days
    • actually and historical data device performace resolution 12 month
    • actually and historical data device performace resolution all years

Also list of devices which are inside plant together with their performance. Also is possible save data's to a file TXT CSV XML JOSN are suported. This program is now partialy working so not every functionality is already implemented as you can see above. You will be advised if you chose not working yet part. When will be finished will have the same usability as text version.

TUI1

huawei-sun2000-api-cli's People

Contributors

blazejosp avatar januweness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

huawei-sun2000-api-cli's Issues

Database schema

Can you share the database schema where the data is stored?

Poblem with functions.sh

Anyone has a problem with this script now from my perspective looks like that Huawei again change something and login function working correct but after that when first question to API about available stations

getStationList

is made error appear. So I asked Huawei support centre about actually reference file pdf and hope that I can fix this. Anyone has the same problem with both interfaces graphical and txt?

getStationRealKpi - problem

I have a problem with this section...

`jq: error (at :1): Cannot iterate over null (null)

API getStationRealKpi connection OK
Normal Status
Time of your Request to API: nie, 30 maj 2021, 15:02:51 CEST

Numbers of plants to check: 1

Plant 1: 
Plant Status: Unknown
Daily energy:  kWh
Monthly energy:  kWh
Lifetime energy:  kWh
Daily revenue:  ¥
Total revenue:  ¥`

API data:
{ "data": null, "failCode": 0, "message": null, "params": { "currentTime": 1622380256531, "stationCodes": "6CD3185EE7074FFCBEF8B4E45AB11328" }, "success": true }

Cannot get any data except "Normal status"

Hello,
Please see below. I am using "Ubuntu 22.04.2 LTS" and installed all the packages as described in the documentation. However, I am not able to get any data, except for the following:

./fusionsolarapp.sh

Please wait connecting!
Connection to API

API login to server OK
Username & Password accepted by Huawei Server
Normal Status
jq: error (at :1): Cannot iterate over null (null)

ndefined Error
\nReturned data:

jq: error (at <stdin>:1): Cannot iterate over null (null)

Hello,
On Dec 9 2022 it was working perfectly.
Starting on 10 Dec 2022 it didn't work. The output error is regarding jq:

Please wait connecting!
Connection to API

API login to server OK
Username & Password accepted by Huawei Server
Normal Status
jq: error (at :1): Cannot iterate over null (null)

ndefined Error
\nReturned data:

What is wrong?
Thank you!

Kioskmode.sh

Kioskmode was working before upgrade in April/May 2021 now need a major redesign because JOSN is different but hope because is not so many data will be possible to made this working again quite fast

API getStationList connection Error

I just received my API credentials from my installer company.
Unfortunately I'm getting the following error:

Connection to API

API login to server OK
Username & Password accepted by Huawei Server
Normal Status
jq: error (at <stdin>:1): Cannot iterate over null (null)

API getStationList connection Error
ou do not have the permission on the related data interface.
Optional message:  "Invalid access to current interface!"

        Plant 1:
        Plant Name:
        Address of the plant:
        Installed capacity:  MWp
        Plant contact:
        Contact phone number:
        Plant Status: Unknown
        Grid connection type: Unknown
        Poverty alleviation plant: Unknown

parse error: Unfinished string at EOF at line 2, column 0
parse error: Unfinished string at EOF at line 2, column 0
Message: Don't know when

Please wait disconnecting!
Disconnection from API

API logout from server OK
Logout accepted by Huawei Server
Normal Status

Am I doing something wrong? Or my installer has forgot to set something up? Mine is the first API account they've set up ever.

Offer to contribute

Hello,

Your project got my interest.
I'm running Domoticz with mqtt and I 'm searching a way to get the data from huwei in my dashboard in Domoticz.
Especially the battery status.

Invert : SUN2000-4.6KTL-L1
Battery : HUAWEI-LUNA2000

If you like, maybe I can contribute to get these devices supported.

kind regards,
Bart

Login error

I followed the instructions and configured the following credentials in config.conf:

declare -A huawei_account_login=(
[login0]="<USERNAME>"
[password0]="**********"
)

declare -A kiosk_mode_url_array=( 
[kioskmode0]="https://eu5.fusionsolar.huawei.com/rest/pvms/web/kiosk/v1/station-kiosk-file?kk=<KIOSK_TOKEN>"
) 

I also tried this URL

https://region01eu5.fusionsolar.huawei.com/pvmswebsite/nologin/assets/build/index.html#/kiosk?kk=<KIOSK_TOKEN>

I'm getting the following error using the same credentials I use for login into the web portal as well:

API login to server Error
Username & Password not accepted by Huawei Server
The third-party system ID does not exist.
Time of your Request to API: Mo 10. Okt 10:19:13 CEST 2022
Your data:
	Username: <USERNAME>
	Password: **********

There is some problem with login_to_API function

Are there restrictions using special charcters in the password?

jq error since 04-03-2023

I have this message. I try some debugging....

Please wait connecting!
Connection to API

API login to server OK
Request success or failure flag: true
Username & Password accepted by Huawei Server
Normal Status
{
"failCode": 305,
"immediately": true,
"message": "USER_MUST_RELOGIN"
}
jq: error (at :1): Cannot iterate over null (null)

ndefined Error
\nReturned data:

order in device_Id_array

In fusionsolarapp.sh you are using static relation to second position in array device_Id_array. You should check type of device because fusion can send device in other order. For example in my installation I received

Device 1: 7534929584736
Smart String Inverter	Inverter Type: SUN2000-5KTL-M0
Device Name: HV20500....
Device SN: HV20500....
Software version: V100R001C00SPC122

Device 2: 45711197793123
Dongle	Device Name: HV20500....
Device SN: HV20500....
Software version: V100R001C00SPC115

XSRF-TOKEN valid time

Hi!
How long is the XSRF-TOKEN token valid or how often does it has to be refreshed?

Problem with login to fusionSolarApp service from this software

During upgrade on Huawei side on their server 26 April to 1st of May service was totally switch off. They switch on their service and open API between 1st to 3rd of May and since then is working. This software especially after upgrade on Huawei side need some rebuild they introduced some changes in API not well documented there is a problem now with login from this software to their API which is partially resolved induced but this small changes by Huawei. I have now last documentation and with help of their Help desk try to resolve this made changes in function login_to_API and hope until end of May this software will work again back like before Huawei upgrade. As for now actually version and a previous one are not working because this problem with login.

Different Huawei setup configurations from Kisoskmode.sh post your own here

Anyone has configuration where is something more than just inverter. That is my
[+] Inverter Huawei SUN2000-M0
[-] Energy battery Storage LG Chem HV or Huawei LUNA
[-] Smart Power Sensor (DDSU666-H)
[-] Solar radiation sensor
[-] SmartLogger 3000

So I'm curious what types of data are available if you have some of this additional devices in your setup like for example DDSU666-H
look on lines 226 to 274 in kioskmode.sh they are based on assumptions so will be great if someone can provide real data
for a while from one of such devices and will be possible put inside this lines real code which can grab additional data.

close to real time

Hi, you can use the data from the inverter then you get 'current power' with minimal delay. thirdData / getDevRealKpi active_power ("devTypeId":"1"). It is faster than data from 'kiosk mode'

Home Assistant integration

As I understood this is the "new" connection method to connect to the SUN2000. Modbus TCP is deprecated?
So it would be great to see this project as Home Assistant integration.

info about fusionsolarapp.sh

Until whole code of fusionsolarapp.sh will be written you my encounter problems with this file not everything is ready. In actually version kioskmode.sh is now fully working with InfluxDB/MQTT/Domoticz and you can use this file for pull basic data or download older version 1.2 where kioskmode.sh&fusionsolarapp.sh are ready to use and can pull simpler data and insert them in InfluxDB and are fully working that is second temporary solution

As for now fusionsolarapp.sh can pull data from Huawei cloud service and show on screen nothing else some parts are temporary hardcoded like positions of Power Plants & Devices inside question to functions look into order in device_Id_array. If you use this new version you must modified them manually to fit to your configuration. But that is because code is in progress and that will be solved in not so long time. Such things will change dynamically in next versions of this file. So If you encounter problems I'm happy to share your solution or propose some on this forum.

If someone of you are in mood for experimenting I mention here some tips for pull more data from this experimental fusionsolarapp.sh

If you look on ${stations_Code_array[0]} I put 0 because I have only one plant and array counting starts from position 0 if you have more you can put there different number equal to your second power plant for example. And pull different data from this second plant.

getStationRealKpi ${stations_Code_array[0]}	
getKpiStationHour ${stations_Code_array[0]} $curent_time
getKpiStationDay ${stations_Code_array[0]} $curent_time
getKpiStationMonth ${stations_Code_array[0]} $curent_time
getKpiStationYear ${stations_Code_array[0]} $curent_time

If you look on this second variable $curent_time we insert into functions actually time but API allows ask for every time since your plants were created. So you can ask about hourly production in historically day actually by hardcoding particular date

# time Sat Jan 30 2021 11:39:40 in unix time ms format for tests
#161200678044
getKpiStationHour ${stations_Code_array[0]} 161200678044

and answer will be production for every hour in 30 January 2021

Use this page to have times for experimenting Epoch converter

The same issue is with particular device info
First we ask about devices inside plant we must insert our station code and number of plants related to our account
like previously my station is only one so have index 0. That ma be different only if you have more plants.

# We start function to get list of devices inside one particular plant
getDevList ${stations_Code_array[0]} $number_of_plants 

We receive answer

API getDevList connection OK
Normal Status
Build Code: 2
Time of your Request to API: nie, 4 kwi 2021, 13:31:14 CEST

Plant 1: XXXXXXXXXX
Number of devices: 2

	Device 1: 5555555555555
	Dongle	Device Name: XXXXXXXXXX
	Device SN: XXXXXXXXXX
	Software version: V100R001C00SPC111

	Device 2: 4444444444444
	Smart String Inverter	Inverter Type: SUN2000-5KTL-M0
	Device Name: XXXXXXXXXX
	Device SN: XXXXXXXXXX
	Software version: V100R001C00SPC120

So we can only ask about parameters of inverter if you ask about dongle you receive error from API you can check yourself. In my case inverter is as Device 2. By indexing in array that is 1 because we start with 0. That is why in question to API I insert ${device_Id_array[1]} below.

# Devices data precision all voltages etc real-time
getDevRealKpi  ${device_Id_array[1]} ${device_TypeId_array[1]}			
getDevFiveMinutes ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiDay ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiMonth ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiYear ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time

In case of variable $curent_time you can experiment with different times inserted manually hardcoded instead of variable into function in the same way like in case of Plants so you should receive data for different time periods.

That is how you can experimenting now until code for that part will be written and such manipulations will be handled by TUI and program itself.

TUI implemended but need feedback about other devices in plant

Now in TUI in real-time function are implemented parts of code which are able to work with various devices which can be connected to plant.
I implemented also other devices which can be inside plant but without testing and verification. If is someone who have them can mention how they work I will be very happy. The are:

  • String inverter
  • Dongle
  • Residential inverter
  • Smart Logger
  • EMI
  • Meter (Grid meter)
  • Power Sensor
  • Battery LG
  • Battery Huawei Luna 2000

Also will be great if someone who have 2 or more plants related with his account can said how this software handle them because that was also implemented without way for checking this.

  • One plant related with account
  • Two plants
  • More until ∞ ;)

Problems with login to huawei server since 30th December 2021 after huawei upgrade

Look like that after server upgrade on Fusionsolarapp Huawei side again something was changed on and function login_to_API in functions.sh can't take correct xsrf token. Result is that when server was resumed again in 30th of December 2021 this software has problem with login to API in both interfaces CLI and TUI. I will try found why now xlrf token is wrong extracted hope that will solve problems. As for now I will be happy if you can check if you have the same problem?

Also a kioskmode is affected but this because is now different URL to API and I think I will solve this quite fast so kioskmode will work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.