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

LUA device parentID


Momos

Question

Hi,

 

I am having some trouble in finding the parentID of the devices in a specific room.  Here it is what i have so far:

Please login or register to see this code.

 

I have no idea on how to get the parentID for each device. 

Would appreciate any help thank you :)  

Edited by Momos
Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • 2 hours ago, petergebruers said:

    fibaro:debug(dev.name.." Id: "..v.."; Device value: "..dev.properties.value .. "; parentId:".. dev.parentId)

     

     

    fails with

     

    [DEBUG] 15:54:21: 2019-01-24 15:54:21.267165 [ fatal] Unknown exception: /opt/fibaro/scenes/127.lua:19: attempt to concatenate field 'value' (a boolean value)

     

     

    Link to comment
    Share on other sites

    • 0

    Ah, amateur mistake by me :)

     

    try

     

    fibaro:debug(dev.name.."   Id: "..v..";  Device value:  ".. tostring(dev.properties.value) .. "; parentId:".. dev.parentId)

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • works :) thank you Peter, great like always.

    Using this code to manually update mesh for an entire room at once :) 

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Now i will abuse a bit as this gave me some interesting idea :)

     

    This is a device as seen from the API:

     

    Please login or register to see this code.

    There is a value which i would like to extract from there, but can not make it work.

    The value is "value\":19,  found under properties.schedules.

     

    I tried variations of:

     

    Please login or register to see this code.

    but it does not work.  

     

    Any idea how to make it work ?

     

    Thank you very much :) 

    Link to comment
    Share on other sites

    • 0

    Ah!

     

    What you are trying to do might prove to be A LOT harder than you think. There are a few obstacles. :)

    1. It is "json in json" - I'll solve that problem in the scene below.
    2. It is actually a nested structure of "schedules" in "blocks" and your example is misleading because it only has one block and one schedule. I will partially solve that problem as well in the scene below.
    3. I am not sure what you want to do, in case you have multiple schedules. So I won't tackle that problem right now.

    Try this. Click on spoiler. I've put it in a spoiler because the code is rather long because of that "api json string" you've posted.

     

    Please login or register to see this spoiler.

     

    I'm not sure how to understand the various fields in "schedules" because it is the first time I have a look at it :)

    I am pretty sure this is a translation of the schedule in my "Heating Panel"... Your devices looks so much simpler, I guess it is not part of the Heating Panel?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi,

     

    I guess i over complicated it or poorly explained it :D

     

    I got a bunch ( a lot :( ) of Danfoss Room Sensor devices... old story.

     

    As they are not integrated in Heating panel i am using a script that reads the set value on them (in case i want to modify the set temperature from the physical buttons) , switches the heating panel for the respective room to manual mode and sets the new temp.

     

    But i never managed to read from the RS the time set using the buttons, as in for how many hours to have that override enabled. So i always set it for 3h.. or a fixed number, disregarding what i set from the physical buttons on the RS.

     

    Looking at http://hc2/docs/devid  and playing with the set value and time on the danfoss RS i noticed that the set time appears in only one place, the one described earlier. 

    So i would like to get that value so i can set the time for the manual override also.

     

    The json exampe i gave was just a copy / paste from http:/hc2/docs/devid so you can see where that value is.

     

    So i was thinking that :


     

    Please login or register to see this code.

    the output is 

    [DEBUG] 12:50:23: Other source.
    [DEBUG] 12:50:23: TermostatRSBirou Id: 619; Device value: 23.5; parentId:617
    [DEBUG] 12:50:23: Processing block_index: 1, with blockId: 0
    [DEBUG] 12:50:23: __Processing schedule_index: 1, with id: 1
    [DEBUG] 12:50:23: ____Duration type: Hours, value: 19

     

    Yay it seems the  duration_value is exactly what i was looking for :)  

     

    Let me work it in me code and see if have a fully functional RS :) 

     

     

     

     

    Edited by Momos
    Link to comment
    Share on other sites

    • 0
    15 minutes ago, Momos said:

    I got a bunch ( a lot :( ) of Danfoss Room Sensor devices... old story.

     

    As they are not integrated in Heating panel i am using a script that reads the set value on them (in case i want to modify the set temperature from the physical buttons) , switches the heating panel for the respective room to manual mode and sets the new temp.

     

    But i never managed to read from the RS the time set using the buttons, as in for how many hours to have that override enabled. So i always set it for 3h.. or a fixed number, disregarding what i set from the physical buttons on the RS.

     

    In this particular case this should work:

     

    Please login or register to see this code.

    As you can see, you were very close with your original attempt, you only missed the fact that "schedules" is an array so you have to select the first element like schedules[1]

    • Thanks 1
    Link to comment
    Share on other sites

    • 0

    Maybe as an alternative. I have several of these RS modules as well, and I use the scene below to overrule the heating panel schedule with the manual temperature set by the RS. Duration can be changed (see scene). Works perfectly for me. After the manual override set by the RS the room goes back to the temperatures/schedule set in the heating panel.

     

    I found the scene somewhere on this forum, credits to someone else :-)

     

    Please login or register to see this code.

     

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @ReneNL yup that's what i was doing until now also :) problem is the override is a fixed value :(  Thanks to @petergebruers now the time is also set according to the danfoss RS button selection :) 

     

    here is the code if anyone needs :

    Please login or register to see this code.

     

    And this is how I started from a manual room mesh reconfiguration and ended up solving a 2 years old problem :)  Thanks again @petergebruers

    Edited by Momos
    • Thanks 2
    Link to comment
    Share on other sites

    • 0

    Great, maybe I copied the scene from you :-) I will also update my scenes accordingly, to be able to set the override with  the RS, thx for sharing!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @ReneNL You might have to soft reconfigure the RS to get that schedule in the API. Mine were installed about 2 years ago. Old ones which i have not yet reconfigured do not have that schedule.  So far i soft reconfigured 5 of them and changed the override scene. All working as it should.  On 2 of them i had to soft reconfigure twice as the icon was wrong for some reason.

     

     

    Link to comment
    Share on other sites

    • 0

    Great, thx. I actually have the Devolo clone of the Danfoss RS. Looks exactly the same, but firmware might be a bit different. I'll check the api to see if the schedule exists. Thx for the tip!

    Link to comment
    Share on other sites

    • 0

    Cool, works! I had to do a soft reconfigure as you indicated to get the schedules being reported.

     

    Thx again.

    Link to comment
    Share on other sites

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