Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Question

Posted

Hi!

 

I have HCL and FIBARO Double Switch 2×1.5kW.

I need to get status of the switch via Rest API.

 

As far as I understand I can do a GET request /api/devices/<device id>.

But I don't quite understand which values are responsible for the on/off states of the switch.

I don't have those devices handy - so I cannot play with this.

 

Would be appreciate for advice.

 

 

And the second question: should I poll those values or is there any way to subscribe on value changes?

 

Thanks you very much in advance!

Kind regards,
Alex

 

 

 

 

 

3 answers to this question

Recommended Posts

  • 0
Posted

json_dict['properties ']['value'] should hold the device state value IIRC, where json_dict is pythonic representation of the returned json structure.

the raw data returned by http request will be something like
{

  "id": "xxx",

  ...

  "properties": {

     ....

     "value": "0",

    ....

  }

}

 

I'm not aware of any way to get triggers out of fibaro ecosystem other than having a LUA scene triggered by value changes for device IDs of interest and having this scene send out http calls to the external server that will initiate rest api callbacks to fetch the json for the triggering devices.
This is how I do it (I have a raspi with a fancy python scheduler and TTS services that complements HC2 LUA stuff)

HC2 -> scene triggered by device ID xxx
HC2 scene ->  POST {"id": "xxx"} to serverIP/api/trigger

server -> GET to hc2IP/api/devices/xxx

server -> process json response

I prefer not to do this if I can as it creates lots of unnecessary traffic and processing delays, so only for something that python domain desperately needs to know, otherwise - keep it in LUA.

 

  • Like 1
  • 0
  • Inquirer
  • Posted
    On 4/30/2019 at 4:20 AM, mika said:

    json_dict['properties ']['value'] should hold the device state value IIRC, where json_dict is pythonic representation of the returned json structure.

    the raw data returned by http request will be something like
    {

      "id": "xxx",

      ...

      "properties": {

         ....

         "value": "0",

        ....

      }

    }

     

     

    The switch has 2 channels, so I need to be able to select the channel as well. Ok. Will need to play on site with JSON )

     

    PS

    Thank you for idea how to send data to the server. 

     

    Kind regards,

     

     

    • 0
    Posted

    I haven't used dual switches, so not sure how they are represented, but I have lots of RGBW devices used as 4-channel 12/24VDC PWM dimmers and each channel gets its own ID, so it's just about using the relevant IDs.
    I think the dual switch should be similar, 1 ID assigned to the master node + 2 IDs for the channels (these are the ones to be used in API)

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...