Ankündigung

Einklappen
Keine Ankündigung bisher.

Huawei sun2000 inverter, fetching data through openapi with changing token

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Huawei sun2000 inverter, fetching data through openapi with changing token

    Hi guys,

    I recently had solar panels installed with a huawei sun2000 inverter. This inverter comes with a nice app that provides all the data from the sun production but alse the energy consumption from the house and the power that is put on the net (due to a linked modbus energy meter). I want to integrate this data as much as possible in loxone, mainly because i want my sunscreens to react based on the amount of sun. Currently my screens are sometimes triggered on a cloudy day when it's too hot inside and no rain is expected.

    I got in touch with Huawei support. Unfortunately you can't fetch this data locally via the ip of the converter (as can be done for sma i think and solaredge). Only possibilities are via RS485 or openapi.
    They provided me with the details to make an openapi connection and gave me an openapi user. I'm however unsure how i can fetch this data in loxone as the openapi request needs to transmit a token that changes everytime and i don't now how to integrate this. I also don't know how to convert the request via postman into a virtual input. I can however fetch the data via postman. Any help on this would be greatly appreciated.

    I've linked the procedure hereunder:

    Request address: https://XXXXX/thirdData/login

    HTTP method: POST

    Request parameter: systemCode and userName

    Use the next link to login: https://eu5.fusionsolar.huawei.com/thirdData/login

    Choose Post, select Body, raw and JSON and insert userName and systemCode(Password) and Send:



    Result:



    After you login copy the Token that you will use to interrogate the next parameters.



    5. Interface of Plant List



    Request address: https://XXXXX/thirdData/getStationList

    HTTP method: POST

    Request parameter:-



    Use the next link to interrogate: https://eu5.fusionsolar.huawei.com/t...getStationList

    Copy the Token in Headers:



    Set the interrogation and send:



    Result:






    Copy the stationCode and current Time to use at the next interrogation.



    6. Interface of Power Station for Real-time Data



    Request address: https://XXXXX/thirdData/getStationRealKpi

    HTTP method: POST

    Request parameter: stationCode

    Use the next link to interrogate: https://eu5.fusionsolar.huawei.com/t...StationRealKpi




    Copy the Token in Headers:



    Set the interrogation: insert the station code from the Plant List and Send:



    Result:


    Zuletzt geändert von ty5500; 19.Jun.2020, 09:26.

  • #2
    I assume your SUN2000 is connected with a Huawei SmartLogger1000? If this is the case, this Smartlogger does the conversion from RS485/modbus RTU to TCP, so you can directly bind it in LoxoneConfig using the Modbusserver function. Since this uses Modbus TCP, there is no need for a modbus hardware extension.
    Check/Google for the Huawei SUN2000 Modbus Interface Definitions document which describes the register definitions.
    In this way, there is no need to connect via the internet/openapi.

    Kommentar


    • #3
      I have unfortunately no smartlogger 1000 and the online prices i see are arround 400 euros. If i cant do it with openapi i'll go for a modbus connection with a modbus extension but i hope i can import the data in loxone via openapi as i can see the necessary data in postman. Thanks however for the help.

      Kommentar


      • #4
        The listed process would be possible to be programmed via e.g. PHP, or a bash script (using curl and jq).
        You could look at GitHub, if someone has already implemented something like this.

        You may also find a ready solution in other home automation systems like FHEM, ioBroker, NodeRed. In this forum and LoxWiki, you will find solutions how to push data to the MS from these systems.
        LoxBerry/Plugin Support: Wenn du einen Begriff in meiner Antwort nicht auf Anhieb verstehst, bitte nicht gleich rückfragen, sondern erst die Suche im LoxWiki und bei Google bemühen.
        PN/PM: Ich bevorzuge die Beantwortung von Fragen in öffentlichen Threads, wo andere mithelfen und mitprofitieren können. Herzlichen Dank!

        Kommentar


        • #5
          The https address effectively precludes the Miniserver directly. But you might want to experiment with Postman using http. It might not be a 'proper' https site.

          The first option I suggest is to use a Loxberry running MQTT and NodeRed. This is a 'non-coding' option that transfers most of the task to the Loxberry with some minor logic blocks in the Miniserver. You could likely solve most of the small steps with questions/answers but you don't need a 'wholistic' coding background to muddle through.

          Loxberry would require a very small expense if you haven't got a Raspberry Pi already. The MQTT Gateway is well documented in the wiki. NodeRed might take some questions/answers to get set up. Plus having a Loxberry is very handy.

          The second option is dependant on the https/http response from the site.
          Ich spreche kein Deutsch. Gib Google Translate die Schuld, wenn ich unverständlich bin.

          Kommentar


          • #6
            Installation of a Loxberry is indeed a good recommendation, and in case you have difficulties getting your openapi application running in nodered, you can use the Loxberry modbus gateway plugin in combination with a cheap modbus USB stick to talk directly to your Sun2000. More info here: :https://www.loxwiki.eu/display/LOXBERRY/Modbus+Gateway

            Kommentar


            • #7
              Hi, thanks for all the feedback. I'll try loxberry to get it going.

              Kommentar


              • #8
                I finally got loxberry on my raspberry pi with the modbus gateway plugin. I linked it with my sun2000 inverter via the RS485 A2 and B2. The RS485 A1 and B1 is linked to my energy meter in my fuse box.

                Klicke auf die Grafik für eine vergrößerte Ansicht  Name: Capture.JPG Ansichten: 0 Größe: 67,9 KB ID: 297855

                The modbus gateway plugin recognises my RS485 to USB stick and is configured.

                Klicke auf die Grafik für eine vergrößerte Ansicht  Name: Capture 2.JPG Ansichten: 0 Größe: 139,4 KB ID: 297856
                Speed on my inverter is also configured on 9600.

                In loxone a modbusserver is configured with the ip of my raspberry. I configured in my loxone a sensor with a command from the modbus interface definitions i found online https://community-openhab-org.s3.dua...c175d59d14.pdf.



                Klicke auf die Grafik für eine vergrößerte Ansicht  Name: Capture3.JPG Ansichten: 0 Größe: 139,0 KB ID: 297859

                I however always get the error "response is incorrect" error. Can someone point me in the right direction because i'm not sure what's wrong. Ip adress is correct, the speed is correct, the data type is correct, the io adress should be correct.

                Klicke auf die Grafik für eine vergrößerte Ansicht  Name: error.JPG Ansichten: 0 Größe: 253,9 KB ID: 297858Any help would be greatly appreciated! thanks!!!
                Zuletzt geändert von ty5500; In den letzten 2 Wochen.

                Kommentar


                • #9
                  I don't have a Huawei inverter but offer the following suggestions for general Modbus connectivity -

                  The Modbus Server should have the Raspberry IP address and port (change the IP to the appropriate number).

                  Set the Timeout to 500ms initially, then increase in 500ms increments if you don't have success.

                  To set a sensor, the IO address needs to be -1 from that published. In the following example I am referring to the Modbus address for "Active power" (Serial Number 36, address 32080).

                  The Huawei document refers to that value having a 'Gain' of 1000. I assume that might mean you need to divide by 1000 to get the actual kW value. The Correction might need to be changed if the value is out by a factor of 1000.
                  Angehängte Dateien
                  Zuletzt geändert von Tico; vor einer Woche.
                  Ich spreche kein Deutsch. Gib Google Translate die Schuld, wenn ich unverständlich bin.

                  Kommentar


                  • ty5500
                    ty5500 kommentierte
                    Kommentar bearbeiten
                    Thanks for the response. So far i had however no luck yet. I'm trying later this week a new usb to rs485 adapter.

                  • Tico
                    Tico kommentierte
                    Kommentar bearbeiten
                    I've just noticed a couple of images I inserted have disappeared. Will try and edit and re-post.

                • #10
                  I finally have values!! Thanks Tico and all. It was a combination of problems.

                  Problem 1: According to the manual port 1 -2 is for a power meter and port 3-4 (rs485 B2 and A2) for a smartbox pv meter to read out the different values. However you also need to use port 1-2 to read out values. A github post pointed me in the right direction. PS i apparently have a SUN2000L, this is different according to the post for the older SUN2000's
                  Klicke auf die Grafik für eine vergrößerte Ansicht  Name: fetch?id=297855&d=1616698471.jpg Ansichten: 0 Größe: 67,9 KB ID: 298973

                  Problem 2: I previously had a modbus power meter linked to the inverter (i think this is the case with most sun2000's). This was previously linked to RS485B1 and RS485B I had to remove this meter in my fusionhome app with an installer account and than only the inverter also started also acting as a modbus slave..
                  Zuletzt geändert von ty5500; vor einer Woche.

                  Kommentar

                  Lädt...
                  X