Announcement

Collapse
No announcement yet.

MyEnergi API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MyEnergi API

    Thanks to Michael on another page I can see how to set up the MyEnergi API with digest authentication and he has confirmed this works for him. I've not used this plugin before and there's a pretty steep learning curve so trying to take it one step at a time.

    There's 2 primary forms of communication, queries and commands:
    1. Query - receives back a JSON package with the value of a large number of variables - https://sX.myenergi.net/cgi-jstatus-*
    Queries can be generic like this or aimed at specific devices Eddy (water controller) or Zappi (electric car charger) by changing the ending of this string.

    Command - sends specific control commands, such as to set the hot water controller to boost - https://s1.myenergi.net/cgi-eddi-boo...XXXXXX-10-1-20. There's quite a number of these as you can control the Eddy (water controller) or Zappi (electric car charger) to various modes so the commands and the extensions vary. The responses to these commands are basic, they don't actually provide confirmation of the new value, merely that the request was received, so after sending such a command it would be good to send a query to get the latest status.

    As I said I'm a complete newbie and a bit lost by the huge volume of documentation on this. If someone can get my started with the basics of sending a command and storing the results of a JSON query to a variable I can expand out from here. Happy to add in links in this thread to the MyEnergi information and the Gthub where the API has been reverse-engineered from the app to make this a useful store of how to integrate HS4 and MyEnergi.

    Thanks!

    #2
    The general organization of mcsMQTT is focused on the MQTT Page, Association tab. This is where mcsMQTT presents every endpoint that a Server transmits/updates and the user can elect to associate this endpoint to a HS Device Feature. JSON payloads are the most common forms of data received. They can be simple one-level set of keys and values or may be organized in multiple levels. mcsMQTT breaks it down using the convention of a colon to separate levels of the JSON payload. For example if {"Device":{"id":1,"name"":myName"}} is the payload then mcsMQTT would presents rows in the association table for
    : Device with no payload because it is a grouping key and not a endpoint
    : Device:id with payload 1
    : Device:name with payload myName

    The source of data for this table is usually a MQTT broker, but in your case you do not have any devices that use MQTT for communication, but you have a URL that can be queried at a specified rate. The URL is specified on the Cloud page of mcsMQTT. You can have as many URLs setup as desired to pull data from different servers or different types of data from the same server.

    In the case of using a URL to communicate to the Server, mcsMQTT will create a control device for this URL. It has two buttons to enable/disable the polling of the Server and a text box to enter the command to be sent. This is likely where you will be focusing for control commands such as for boost. Once the set of control commands that you want to activate through HS are understood then I can recommend an approach on how to organize for ease of use.

    What you need now is to install mcsMQTT from the Updater. Get the delta update from http://mcsSprinklers.com/MCSMQTTHS4_52021.zip. Unzip the .html into \html\mcsMQTT and the other two into \bin\mcsMQTT folder.

    Enable the plugin and select the Cloud page where you enter the URL and credentials. For initial testing leave the poll rate at 0 so you have better control of when data is updated. Go to the HS Devices page and look for the newly created device in the floor URL. Enter something in the text box (such as ?) and click Submit button. Go to plugin's MQTT Page, Association tab. You should see a number of rows of decoded JSON data. Pick something of interest by using the "a" checkbox on that row. Go to HS Devices page and now you will see an additional Feature in the floor URL.

    This is step 1 to confirm you are able to get status information from the URL. Next give me some specific commands that you will want to exercise. I will then provide guidance on how they can be specified.

    I would suggest not reading mcsMQTT user guide as your use case is not a MQTT interface so most of the information is not needed for what you need to do. My email is mcsSolutions at CenturyTel dot net. This will be easier to use when private information needs to be communicated. We are probably eight hours apart.

    Comment


      #3
      What I see from twonk/MyEnergi-App-Api: Investigation of the MyEnergi App (github.com) for control

      ZAPPI

      # is the Zappi Serial Number
      M is 1=Fast, 2=Eco, 3=Eco+
      K is KWh to add to boost
      T is HHMM to complete boost
      G is percent minimum green level

      Code:
      Zappi Mode     /cgi-zappi-mode-Z########-M-0-0-0000
      Boost              /cgi-zappi-mode-Z########-0-10-K-TTTT
      Boost Stop     /cgi-zappi-mode-Z########-0-2-0-0000
      Green Level   /cgi-set-min-green-Z########-GGG
      EDDI

      # is Eddi Serial Number
      H is Heater number 1 or 2
      MM is minutes

      Code:
      Eddi Boost       /cgi-eddi-boost-E########-10-H-MM
      Eddi Stop         /cgi-eddi-boost-E########-0
      Eddi Normal     /cgi-eddi-boost-E########-1
      Heater Priority  /cgi-set-heater-priority-E########-2

      Which of these capabilities will be useful? What UI will be convient?

      For example, If there is a Zappi Mode HS Feature it could have 3 VSP values so one device could control all modes

      If Boost with time is to be used then it needs both K and T parameters. HS does not do well with multiple pieces of information in a Feature. I think the Event Action becomes the control approach in this case where where K and T could be in individual devices so the Event Action would look something like below. Alternately there may be just a few boost settings that would be used so an event for each and the values hardcoded such as the second line in the example for 5Kwh at 16:00.

      Code:
      URL/cgi-zappi-mode-Z12345678-0-10-$$DVR: (100):-$$DTR: (101)
      URL/cgi-zappi-mode-Z12345678-0-10-5-1600
      Another factor is the relationship of the status information received in the polling URL(s). Is there a Zappi mode reported that could be associated with a control for the Zappi mode. Same question for any control that you would like to use.

      Comment


        #4
        I played a little more with your account to evaluate other status reporting. mcsMQTT had looked for a starting { to recognize JSON. The status payload starts with list specifier [. I updated mcsMQTT in 5.20.2.1 to recognize this. Available at http://mcsSprinklers.com/MCSMQTTHS4_52021.zip for HS4. The link in post #2 guidance was also updated to this version.

        I also see where the base URL should be setup on the Cloud page and not the full endpoint. This allows one URL to be used for various status and commands. I have slow internet and I would get timeouts on query so I explicitly specified the timeout of 15000 milliseconds rather than the default 5000.

        Click image for larger version

Name:	Capture.PNG
Views:	702
Size:	34.1 KB
ID:	1499809

        I just picked one of the status items to associate with a HS device. I also entered a Publish endpoint that was just a request for status so I would not be controlling anything on you system. Post #3 endpoints would be used in an actual situation. The status device would also be a more reasonable one to attach a control. This was just done so I could confirm the logic was working as expected.

        Click image for larger version

Name:	Capture1.PNG
Views:	610
Size:	298.7 KB
ID:	1499810

        The HS device view of 933 and 939 looks like the following. This is where a change in initial guidance is needed. Since the Cloud page was changed to the base URL the endpoint now needs to be specified in the text box for the control device. 933 is produced when the Cloud page URL is defined. 939 was produced when the "a" column checkbox was clicked.

        Click image for larger version

Name:	Capture2.PNG
Views:	610
Size:	31.1 KB
ID:	1499811

        When the Submit button is pressed the contents of the text box for 933 is suffixed to the base URL to request status for E. When the Send button is pressed a request will be sent for all status based upon the Association table Pub topic for device 939 in the prior figure. The stop and start polling buttons are mute at this time because the polling interval was setup to be 0 on the Cloud page.

        No rush to do any testing or provide feedback. I just wanted to make certain you should have a problem-free experience and be prepared to answer questions.



        Comment


          #5
          Wow, this is a very unexpected find.
          I am also using MyEnergy (Zappi and Harvi) and i made a first issue vb script to pull the data into HS3. However i see this is also possible with MSCMQTT. I didn't know about the cloud tab.
          I will follow this thread closely and I am very interrested.
          If there is need for testdata or testing then i might be able to help too.
          - Bram

          Send from my Commodore VIC-20

          Ashai_Rey____________________________________________________________ ________________
          HS3 Pro 3.0.0.534
          PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

          Comment


            #6
            Feel free to jump in and share you viewpoint on the control endpoints and any other usage aspects. The data I linked in post #3 does not contain Harvi Do you have information about control URLs for this product?

            Comment


              #7
              When the URL IP was changed from the endpoint to the base address of the server then a change was also necessary to support polling where the polling endpoint needs to be entered. This was done in 5.20.22. I also determined that no additional headers are needed, except in my case where timeout needed to be extended.

              HS3: http://mcsSprinklers.com/MCSMQTT_52022.zip
              HS4: http://mcsSprinklers.com/MCSMQTTHS4_52022.zip

              Click image for larger version

Name:	Capture.PNG
Views:	611
Size:	146.9 KB
ID:	1500031

              Comment


                #8
                Originally posted by Michael McSharry View Post
                Feel free to jump in and share you viewpoint on the control endpoints and any other usage aspects. The data I linked in post #3 does not contain Harvi Do you have information about control URLs for this product?
                I will see what i can find about the Harvi.
                An harvi is used in the same system to collect data via current clamps. It monitors the kw used by all the auxelairy equipment but it can also monitor your solar system so you can charge only when there is surplus energy.

                More info about the device here
                Energy Harvesting Wireless Sensor | harvi | myenergi UK

                I will see if i also got a linke to the JSON data.. I have it in my script
                - Bram

                Send from my Commodore VIC-20

                Ashai_Rey____________________________________________________________ ________________
                HS3 Pro 3.0.0.534
                PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                Comment


                  #9
                  Here's some additinal info

                  This URL gives you all the information of the system polled in JSON
                  https://s<last digit of the MyEnergy hub>.myenergi.net/cgi-jstatus-*
                  e.g. When your serial number ends with a 4 then use this https://s4.myenergi.net/cgi-jstatus-*

                  Code:
                  Public Class Harvi
                    Public Property sno As Integer ' Serial no
                    Public Property dat As String ' Date
                    Public Property tim As String ' time
                    Public Property ectp1 As Integer ' CT1 - Watt
                    Public Property ectp2 As Integer ' CT2 - Watt
                    Public Property ectp3 As Integer ' CT3 - Watt
                    Public Property ectt1 As String ' CT1 - Measuring type for example 'Grid', 'Generation'
                    Public Property ectt2 As String ' CT2 - Measuring type for example 'Grid'
                    Public Property ectt3 As String ' CT3 - Measuring type for example 'Grid'
                    Public Property ect1p As Integer ' CT1 - Phase connected to ??
                    Public Property ect2p As Integer ' CT2 - Phase connected to ??
                    Public Property ect3p As Integer ' CT3 - Phase connected to ??
                    Public Property fwv As String ' Not in use
                  End Class
                  
                  Example JSON with 2 Harvi's (Serial no is edited)
                  
                  {"harvi":[{"sno":110549xxx,"dat":"31-08-2021","tim":"14:47:52","ectp1":997,"ectp2":170,"ectp3":-3022,"ectt1":"Grid","ectt2":"Grid","ectt3":"Grid","ect1p":1, "ect2p":2,"ect3p":3,"fwv":""},
                  {"sno":10654xxx,"dat":"31-08-2021","tim":"14:47:52","ectp2":-46,"ectp3":3037,"ectt1":"Generation","ectt2":"Generation","e ctt3":"Generation","ect1p":1,"ect2p":2,"ect3p":3,"fwv":""}
                  ]}
                  
                  The firmware can be found in the asn: tag of the response
                  {"asn":"s18.myenergi.net","fwv":"3401S3051"}]
                  - Bram

                  Send from my Commodore VIC-20

                  Ashai_Rey____________________________________________________________ ________________
                  HS3 Pro 3.0.0.534
                  PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                  Comment


                    #10
                    The links in post #7 aren't working.
                    - Bram

                    Send from my Commodore VIC-20

                    Ashai_Rey____________________________________________________________ ________________
                    HS3 Pro 3.0.0.534
                    PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                    Comment


                      #11
                      I had GoDaddy reset the host server and the links are now functional from my browser.

                      The URL you show in post #9 does give total status. The question is for the control documented in post #3 for two of the items, but not Harvi.

                      Comment


                        #12
                        I can confirm that the links is working again.

                        About the Harvi.
                        Yes you are right. The harvi is a data collector and can't be controlled. However it can provide data for the logic in HS.
                        Also, an Eddi and the Zappi have also connection point for a CT clamps. If these are in use then you need to use a Harvie for extra data collection. This data is also fed into the master device (Eddi or Zappy) and they can make decisions based upon this data.
                        But the Eddie and/or the Zappi are the devices that can be controled.
                        - Bram

                        Send from my Commodore VIC-20

                        Ashai_Rey____________________________________________________________ ________________
                        HS3 Pro 3.0.0.534
                        PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                        Comment


                          #13
                          Just replaced the dll with version from the 52022 zip file
                          Please note that the version on the manage page isn't updated and still at 50.20.1.3
                          - Bram

                          Send from my Commodore VIC-20

                          Ashai_Rey____________________________________________________________ ________________
                          HS3 Pro 3.0.0.534
                          PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                          Comment


                            #14
                            The MQTT Page General tab first heading contains the version number of the .dll which contains all the plugin-specific logic. The HSPI_MCSMQTT.exe is the HS wrapper that shows in the HS Manage page.

                            Thank You for clearing up control for Harvi

                            Comment


                              #15
                              This is fantastic Michael, thanks! I had mcsmqtt installed before and I think it's caused me some problems. I have tried removing all references, deleting any mcs files anywhere in HS4 install directory, restarting HS4, re-installing the plugin and applying the 5.2.20 updates. I can see in the debug log the polling is working successfully, but I'm not getting any devices created and getting this in the HS4 log:

                              10/04/2021 08:43:20
                              HomeSeer
                              Warning
                              Error displaying device (1) URL s1.myenergi.net:Control s1.myenergi.net:Control:A status graphic with that value set already exists Check with the owner of the plugin that created this device.

                              Polling is working, as I can see this in the debug log:
                              04/10/2021 08:43:17 826804 | ActOnMessageForTrigger QueueSize=0 ,Topic URL/s1.myenergi.net:GET,Payload {"eddi":[{"dat":"04-10-2021","tim":"07:41:15","frq":49.96,"gen":711,"grd":351,"hno" :1,"pha":1,"sno":14303630,"sta":1,"vol":2348,"ht1":"Tank 1","ht2":"Tank 2","tp1":127,"tp2":127,"pri":1,"cmt":254,"che":0.00,"ectp 2": 370,"ectp3":711,"ectt1":"Internal Load","ectt2":"Grid","ectt3":"Generation","fwv":"3200S3.048" ,"dst":1,"hpri":1}
                              ]},{"zappi":[{"dat":"04-10-2021","tim":"07:41:15","ectp2":-3,"ectp3":4,"ectt1":"Internal Load","ectt2":"Grid","ectt3":"None","frq":50.01,"gen":711,"g rd":351,"pha":1,"sno":15511519,"sta":1,"vol":2376,"pri":1, "c mt":254,"zmo":2,"tbk":5,"che":0.00,"pst":"A","mgl":50,"sbh ": 17,"sbk":5,"ectt4":"None","ectt5":"None","ectt6":"None","fw v ":"3560S3.142","dst":1,"lck":16,"pwm":5300,"zs":256,"rdc ":-4,"rac":4,"rrac":-8,"zsh":1}
                              ]},{"harvi":[]},{"asn":"s1.myenergi.net","fwv":"3401S3077"}

                              I can also successfully send commands like boost to the Eddi from the control device.

                              I'm using the config exactly as per post #7. I think due to the error above it can't create the devices, so I'm only seeing the base device in the config table. Any ideas how I get rid of the error or force the config to show so I can refresh the devices?

                              Comment

                              Working...
                              X