Interfacing with Cortex

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • jpdw
    Automated Home Guru
    • Oct 2007
    • 169

    Interfacing with Cortex

    Probably a simple question but I've not been Keeping Up At The Back recently.... And it's testament to the stability of cortex that it's taken me 40 minutes of faffing to even "remember" the credentials to log into my cortex PC for the first time in many many months...!

    I'm using some old scripts to 'talk' xAP with cortex -- to send in some additional data and extract/report on heating status. I need to re-write them and don't want to use xAP if I can help it....
    Can I use something more modern? I have a feeling there's some means of JSON API over the network.

    Thanks all.
    Jon
  • Karam
    Automated Home Legend
    • Mar 2005
    • 863

    #2
    Yes, I would suggest the Cortex Web API which provides JSON, XML and our own Synapse formats of syntax. You will need to have the Cortex Mobile licence to use this and I would suggest your Cortex is updated to the latest available version (27.2.6). Go to Tools | Cortex API and on bottom of page choose the Web API via Web Server tab then read associated Help.
    Last edited by Karam; 9 September 2017, 09:54 AM.

    Comment

    • jpdw
      Automated Home Guru
      • Oct 2007
      • 169

      #3
      That seems to be just the job. Thanks. The old xAP-based 'glue' can go in the bin......
      Jon

      Comment

      • chris_j_hunter
        Automated Home Legend
        • Dec 2007
        • 1713

        #4
        good luck with that, would be interested to read more detail, including how it goes ...

        we've done something similar (may not be quite the same) to feed weather forecasts to NoticeBoard & our tablets - which works well - albeit we're going to have remind ourselves of the details soon, because the Met.Office has given notice of changing things at their end ...
        Last edited by chris_j_hunter; 10 September 2017, 01:08 AM.
        Our self-build - going further with HA...

        Comment

        • westernm
          Automated Home Jr Member
          • Apr 2008
          • 22

          #5
          It would be good to hear how you do. We use the Web API to communicate with our Pellet Boiler.
          It integrates nicely as we also use Cortex to control our UFH/Radiators and to monitor the water temperature available to the various central heating components i.e. Boiler, Thermal Store, Water Cylinder etc.
          Its great for tracking relationships between operating times of the boiler and the impact on water temperature through daily use of heating and hot water. It can also be used to boost the boiler to ensure there is enough hot water for the kids bathtime.


          Mark

          Comment

          • jpdw
            Automated Home Guru
            • Oct 2007
            • 169

            #6
            I've enabled Cortex web and from a bash prompt I've been able to do some basic querying with http GETs
            e.g. curl "http://userassword@10.1.1.30/api/v1/json/Objects/492"
            and getting a meaningful-looking chunk of JSON back out - which is good.

            Looking at it, this should be relatively easy to parse in Python - so before breaking into that I thought I'd also try to prove out doing the reverse -- poking things back into Cortex:

            I'd like to be able to enable/disable HVAC zones and to 'simulate' pressing some of the buttons on physical modules (like you can do on the Behaviour dialog of the modules in Cortex. But I can't seem to set any values/ports -- I've tried a few things, from trying to change states on things, text descriptions or values.

            I assumed I need to POST to write. Initially any attempt to POST got rejected but then I realised I needed to allow Mode = "control" in the webserver settings. Now I get a 405 with "Get action required to query port value" when I try a POST...

            ➜ ~ curl -X POST --data "Value=0" "http://userassword@10.1.1.30/api/v1/json/Ports/492/11?Value=0"
            <CortexAPI>
            <Code>405</Code>
            <Message>GET action required to query port value</Message>
            </CortexAPI>
            (where 492 is a temperature module and port 11 is an additional input)
            Last edited by jpdw; 16 September 2017, 12:31 AM.
            Jon

            Comment

            • jpdw
              Automated Home Guru
              • Oct 2007
              • 169

              #7
              Something of a breakthrough. As posted yesterday, I just could not get data to POST into cortex.
              Try as I might, the details in Cortex manual/help wouldn't work for me:
              /api/v1/Ports/ObjectIdentifier?PortIdentifier=Value
              and
              /api/v1/Properties/ObjectIdentifier?PropertyName=Value

              Then I went back to the examples in the Cortex API / Simulation dialog. Selected "Set Port Value by IDNumber and Port Number

              The API Simulation comes up as

              /api/v1/Objects/ ?4=1

              Ah... Objects... Not Ports or Properties.... And trying 'curl -v -d "11=8" "http://admin:admin@10.1.1.30/api/v1/json/Objects/475" ' works - a sacrificial test object on the screen gets the number I've sent it !!!

              Not sure if this is a typo in the help doc or just my misunderstanding - but the Objects URIs listed in the Resource Identifier section of the Cortex API Web help only mention listing and not setting values....

              Anyway, I think I can now continue....
              Jon

              Comment

              • Paul_B
                Automated Home Legend
                • Jul 2006
                • 608

                #8
                Thanks for sharing this information, useful to know the structure of interacting with the Cortex Web API. Might have a go this week using PowerShell as it is native to Windows 10. Done something similar with blockchain queries so shouldn't be that hard now you've shared the basics.

                Cheers

                Paul

                Comment

                • chris_j_hunter
                  Automated Home Legend
                  • Dec 2007
                  • 1713

                  #9
                  PowerShell works also with Win'8.1 (& Win'7/SP1) - so would be great if you posted a few simple examples of what you get to work ... nothing elaborate, just a few lines to get us started !

                  Chris
                  Our self-build - going further with HA...

                  Comment

                  • Paul_B
                    Automated Home Legend
                    • Jul 2006
                    • 608

                    #10
                    Hi
                    Originally posted by chris_j_hunter View Post
                    Chris
                    rather than hijack this thread and the information from
                    Originally posted by jpdw
                    jpdw
                    I have created a new thread with an extended explanation of using PowerShell



                    Paul

                    Comment

                    • AikenDrum
                      Automated Home Lurker
                      • Jan 2018
                      • 2

                      #11
                      I am looking at a similar issue, trying to get an Amazon lamda function to utilise the Idratek Cortex API so that I can use and Amazon alexa Smart home skill.
                      I've had some success with controlling lights on/off using POST to /api/v1/json/Objects.json/objId?PortId=1 (using ports 5 & 6).
                      I'm now trying to get info on current state - although seems to need GET to /api/v1/json/Ports.json/objId/PortId - anyone found a good reference for the ports / properties etc.

                      Thanks,
                      A

                      Comment

                      Working...
                      X