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


  • 0

How to string.sub API string?


Question

Posted

Hello fibaro people,

I'm trying to figure out how to get values from api string. I can get a long string from 'HCID/api/panels/heating?id=4', but I can't get the values of it.

for example I get:

{"id":4,"name":"Svetaine","properties":{"monday":{"morning":{"hour":6,"minute":0,"temperature":33},"day":{"hour":12,"minute":0,"temperature":33},"evening":

.......................................................................................................................................

......................................................................................................................................

.......................................................................................................................................

{"hour":0,"minute":0,"temperature":33}},"handTemperature":0,"handTimestamp":1410518435,"vacationTemperature":6,"rooms":[11]},"created":1411105699,"modified":1411105699}

And I want to get morning temperature from it...

Any thoughts?

5 answers to this question

Recommended Posts

  • 0
Posted

gediminasv705, that is json, so use json.decode. Example you can saw in virtual device with heating (few of them you can saw on forum)

  • 0
  • Inquirer
  • Posted

    I tried to use json.decode, but got an error message: [ERROR] 17:51:26: line 13: calling 'decode' on bad self (expected 1 argument)

    Can anybody give me an example? I tried to search in forum, but couldn't find any (please, post a link, if you saw any example with json in virtual device).

    Thank you

    • 0
    Posted

    Hi gediminasv705,

    Please login or register to see this link.

    is what you're looking for.

    Edit: Please note that this will only work in a virtual device, not a scene.

    Happy Automating,

    Adam Bewsher

    • 0
    Posted

    Adam.Bewsher, it will also work in scenes but from version 4.017+

    • 0
    Posted

    Thanks A.Socha, good point!

    For everyone not yet using 4.017+, don't get frustrated if your code doesn't work in a scene, just move it to a virtual device - you can call the virtual device buttons from a scene if you need it to be triggered.

    Happy Automating,

    Adam Bewsher

    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...