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


[SUBMITTED][Feature Request[ - Ability to disable all virtual devices and scenes


AutoFrank

Recommended Posts

Hi,

I'd like to request the ability to disable all scenes and virtual devices through a checkbox option.

It could be added under the Configuration section and have a separate check box for scenes and vd's.

 

Please login or register to see this image.

/monthly_2017_08/Capture.PNG.29d24466001141424bec6d1513951cc6.PNG" alt="Capture.PNG.29d24466001141424bec6d1513951cc6.PNG" />

 

I believe the capability exists already for scenes and for virtual devices it would be just a simple case of stopping the main loop code.

It would essentially stop all the automation on the HCX device

 

I had a mechanism to do this through a global variable but when I added this to all my scenes and vd main loop, it seemed to cause issues on start up.

I have since disabled this until I find out what the issue was.

 

I found this very beneficial for when I was adding new devices but it could also be useful when upgrading the  HCX fw 

 

Thanks for considering 

_f

 

 

Link to comment
Share on other sites

Good suggestion @AutoFrank,

 

and if I may add that all scenes and VD's can be stopped at the same time through one global check box in Configuration panel. Possibility to do that also using REST API even better.

 

Link to comment
Share on other sites

  • Topic Author
  • 1 hour ago, Sankotronic said:

    Possibility to do that also using REST API even better.

     

    @Sankotronic.. yes, this would be very powerful ....

    Link to comment
    Share on other sites

    Hi!

     

    Could you elaborate on the purpose of this action? Due to my knowledge, all services are stopped anyway before firmware upgrade.

    Link to comment
    Share on other sites

  • Topic Author
  • 25 minutes ago, I.Srodka said:

    Hi!

     

    Could you elaborate on the purpose of this action? Due to my knowledge, all services are stopped anyway before firmware upgrade.

     

    HI @I.Srodka

     

    The main purpose is to stop all scenes and/or virtual devices across the whole system.

    MY setup has grown quite large with many interactions between the physical devices/api/external services and systems.

    I found that if I disabled all the scenes and vd's I could add new devices to my setup much easier and they added first time.

    The request is more for large/complex systems so new devices can be added more easily

     

    Does that make sense ?

     

    _f

    Link to comment
    Share on other sites

    Hi again,

     

    Yes, your suggestion makes sense. I will forward it to the right people for consideration.

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, I.Srodka said:

    Hi again,

     

    Yes, your suggestion makes sense. I will forward it to the right people for consideration.

    Thanks @I.Srodka

    Link to comment
    Share on other sites

    For now you can create a scene which can enumerate all scenes (excluding itself) and if they enabled setting them to disabled via setSceneRunConfig. Of course write results (scene id and the way how was set) down to variable to be able to re-enable them all later (with same or different scene).

     

    For VD's it is bit more tricky, VD's are actually lua scenes, running in own process, here VD with ID 4425

     

    Please login or register to see this code.

    you can't just do stopMainLoop as something like this didn't exists. Fibaro is killing the PluginManager process if necessary (e.g. for backups). There are of course ways to do something, but i will not explain them due to Fibaro warranty restrictions. 

     

    One can of course enumerate all devices  (and check if type == virtual_device) and replace the "mainLoop":" your main loop code will follow here" with "mainLoop":"".

    Your main-loop-code can be then saved in one step into disable/hidden scene (to not lose lua formatting), with scene name=vd id (to be able to restore in single step back from scene to VD), but this is dangerous as when something wrong you will lose your VD main loop code.

     

    However, there is very simple way to stop any VD, just add this line as first line in each every VD:

    Please login or register to see this code.

    once you set STOPALL variable to 1, the main loop will stop the remaining code from execution. Setting back to "0" will not re-start main loop's, you will have to reboot HC2 or click on "save" button of (any) VD (but this is actually cool, as one can stop all VD's, change variable to "0" and click on save only on one VD to get only this one running, e.g. for test reason).

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 12 hours ago, tinman said:

    For now you can create a scene which can enumerate all scenes (excluding itself) and if they enabled setting them to disabled via setSceneRunConfig. Of course write results (scene id and the way how was set) down to variable to be able to re-enable them all later (with same or different scene).

     

    For VD's it is bit more tricky, VD's are actually lua scenes, running in own process, here VD with ID 4425

     

    Please login or register to see this code.

    you can't just do stopMainLoop as something like this didn't exists. Fibaro is killing the PluginManager process if necessary (e.g. for backups). There are of course ways to do something, but i will not explain them due to Fibaro warranty restrictions. 

     

    One can of course enumerate all devices  (and check if type == virtual_device) and replace the "mainLoop":" your main loop code will follow here" with "mainLoop":"".

    Your main-loop-code can be then saved in one step into disable/hidden scene (to not lose lua formatting), with scene name=vd id (to be able to restore in single step back from scene to VD), but this is dangerous as when something wrong you will lose your VD main loop code.

     

    However, there is very simple way to stop any VD, just add this line as first line in each every VD:

    Please login or register to see this code.

    once you set STOPALL variable to 1, the main loop will stop the remaining code from execution. Setting back to "0" will not re-start main loop's, you will have to reboot HC2 or click on "save" button of (any) VD (but this is actually cool, as one can stop all VD's, change variable to "0" and click on save only on one VD to get only this one running, e.g. for test reason).

     

     

     

    Thanks @tinman

     

    I had a solution using the global variable to fibaro:abort() for both scenes and vd but when I added it to all my vd's and scenes I started to get a few weird anomolies so I removed it until I could investigate it more]

    I thought it had something to do with all scenes and vd main loops querying the one global variable all the time but I'm not sure

     

     

    I must look at your method to stop all scenes and may evolve my previous solution and could perhaps use multiple globals/variables 

     

    You use "break end" .. Is this better or the same as fibaro:abort()

     

    Thanks

     

     

     

    Link to comment
    Share on other sites

    fibaro:abort is os.exit, (which then send kill to the interpreter) where break (VD mainloop is while loop) exits the while loop. For scenes one can't use break as there is no while, so that's why fibaro:abort (os.exit) can be useful. As said above, when you disable all scenes in first place, you have not to kill anything (i don't like the idea of triggering on something and killing then, when i can stop the triggering directly). For VDs there is no API call for that, so that's why we have to use for now something different. Regards your question, for VDs you can use both, fibaro:abort or break (return false is ok as well), in the main loop there is nothing to return/care about so no difference. When you think to implement VD for that, as mentioned above for scenes, do not forget to check for and skip itself, to avoid strange errors.

     

    This is part of what we are using:

    Please login or register to see this code.

     

    Edited by tinman
    some code
    Link to comment
    Share on other sites

    Hi @tinman,

     

    Nice peace of code; very usable :-) Thank you for sharing this.

     

    I changed few lines to make the result more readable for me:

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    I'd like to see this as a recovery option.

    Case:

    You are developing a scene or VD and made a huge mistake and it sends your system into the well known 503 nightmare.

    1. I'd like an extra option in the recovery menu: safe boot, just a functioning GUI and scene/ VD editor, but no running scene's VD or z-wave.

    2. Or if this is not possible, when rebooting the HC2, no running scenes or VD's for i.e. 5 minutes (maybe cancelable in the config menu after a reboot) so you have time to disable/ edit the offending scene/ VD.

     

    I know option 1 is possible because of a bug I sometimes experience when making a backup or after a reboot (posted on this forum so Fibaro is aware).

     

    Jim

     

    Link to comment
    Share on other sites

    I just wonder, for scenes would't be enough to set them to MANUAL_ONLY?

    Please login or register to see this code.

    I tested this and when scene is set to this state if it was running it will stop running, and scenes with trigger will not start on trigger any more. It can be run only manually. The best is that scenes that where running with autostart will continue running after scene state is set back to 'TRIGGER_AND_MANUAL', while scenes that are run by trigger will not start if where stopped while running. 

     

    Also, why stop completely VD Main loop from running? Wouldn't be enough just to skip complete code if global variable STOPALL is set to true and maybe even use longer delay like:

    Please login or register to see this code.

    I know that in this case Main loops are still running but it might be just enough to skip code that is normally executed to get more resources? Just thinking aloud :-) 

    Link to comment
    Share on other sites

  • Topic Author
  • On 8/7/2017 at 3:32 PM, I.Srodka said:

    Hi again,

     

    Yes, your suggestion makes sense. I will forward it to the right people for consideration.

    Thanks @I.Srodka

    Hi 

    All good ideas .. I think when I'm back at home I'll refine this using some of the suggestions above 

     

    Thanks for sharing ..

     

     

    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
    Reply to this topic...

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