Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Interfacing with Cortex

  1. #1
    Automated Home Guru jpdw's Avatar
    Join Date
    Oct 2007
    Posts
    168

    Default 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

  2. #2
    Automated Home Legend Karam's Avatar
    Join Date
    Mar 2005
    Posts
    817

    Default

    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; 9th September 2017 at 09:54 AM.

  3. #3
    Automated Home Guru jpdw's Avatar
    Join Date
    Oct 2007
    Posts
    168

    Default

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

  4. #4
    Automated Home Legend chris_j_hunter's Avatar
    Join Date
    Dec 2007
    Location
    North Lancashire
    Posts
    1,674

    Default

    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; 10th September 2017 at 01:08 AM.

  5. #5
    Automated Home Jr Member
    Join Date
    Apr 2008
    Posts
    20

    Default

    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

  6. #6
    Automated Home Guru jpdw's Avatar
    Join Date
    Oct 2007
    Posts
    168

    Default

    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; 16th September 2017 at 12:31 AM.
    Jon

  7. #7
    Automated Home Guru jpdw's Avatar
    Join Date
    Oct 2007
    Posts
    168

    Default

    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

  8. #8
    Automated Home Legend Paul_B's Avatar
    Join Date
    Jul 2006
    Location
    Eastbourne, UK
    Posts
    603

    Default

    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

  9. #9
    Automated Home Legend chris_j_hunter's Avatar
    Join Date
    Dec 2007
    Location
    North Lancashire
    Posts
    1,674

    Default

    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

  10. #10
    Automated Home Legend Paul_B's Avatar
    Join Date
    Jul 2006
    Location
    Eastbourne, UK
    Posts
    603

    Default

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

    http://www.automatedhome.co.uk/vbull...ing-PowerShell

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •