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

[VD] - Checking for VD's that have stopped in error


Question

Posted (edited)

Hi,

 

This may help weed out some bugs

 

Occasionally I have a VD that stops or error out. This could apply to a Main Loop or a Button,

It may be because a sensor has become unavailable and the code is trying to compare something to nil or blank, etc 

I know that if the code was written with a lot if resilience then this wouldn't happen but sometimes time or knowledge doesn't enable this to happen

This would also be considered a way to find those corner cases and modify the code to handle these exceptions better

 

A good example would be the following (sonos api was unavailable during a reboot) and it error out

I have been modifying my code to handle these scenarios but haven't got around to all cases yet.

 

Please login or register to see this attachment.

 

If I save the VD, it will go away (as the api is back online) until the next time 

 

So I put this little VD together to scan all virtual devices on your system and report any that have stopped (at this moment it won't detect if it is main loop or a button so you'll just have to check then all for any VD that comes up red)

 

The output is as follows

Please login or register to see this attachment.

 

You can see id 420 (Living room remote) that was the example above) and I found I had others as well :-( but all opportunities to improve things.

I have mine running daily with the output being sent to me through my message hub

 

The VD code is as follows

Please login or register to see this code.

I have also added the VD below to save you creating your own...

 

INSTRUCTIONS

  1. Import the VD
  2. Open Debug Window for "Run Scan" and start the scan
  3. The report-out is in the debug window

 

Lastly if you want to check that this is working them import the VD marked "deliberate error" and it will show up when you scan

 

Enjoy 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by AutoFrank
  • Like 1
  • Thanks 1

3 answers to this question

Recommended Posts

  • 0
Posted

@AutoFrank

Looks good.

May I suggest to use api.get() function instead of FHttp, works better.. no need to check errors and json converting.

Again.. looks good

.

  • 0
  • Inquirer
  • Posted
    19 minutes ago, cag014 said:

    May I suggest to use api.get() function instead of FHttp, works better

     

    Thanks @cag014

    I'll look into modifying to using that approach

     

     

    • 0
    Posted

    My VDs occasionally get a nil value when getting device value or global variables. I have no clue why this happens. It increased with with 140 update.

    Is there a way to automatically restart the VDs?

    I would hate to write the check for 'if xx == nil then...' every time I try to get any kind of variable...

     

     

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