Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
FIBARO Home Center App 1.0.0 - release Read more... ×
FIBARO Home Center App 1.0.0 - wydanie Read more... ×
  • 0
Momos

LUA device parentID

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

Share this post


Link to post
Share on other sites

14 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)

     

     

    Share this post


    Link to post
    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)

     

     

    Share this post


    Link to post
    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 :) 

     

     

    Share this post


    Link to post
    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 :) 

    Share this post


    Link to post
    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?

    Share this post


    Link to post
    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

    Share this post


    Link to post
    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

    Share this post


    Link to post
    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

    Share this post


    Link to post
    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

    Share this post


    Link to post
    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!

    Share this post


    Link to post
    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.

     

     

    Share this post


    Link to post
    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!

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×