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

Reboot ADSL router if line is down


RiccardoCanetta
 Share

Question

Hi,

I'm trying to implement a script that reboots (through Fibaro power module) my ADSL router if the line is down, so that I don't have to send my neighbor to unplug/plug the router when I'm not able to reach HC2 anymore...

This is the script I created in a Virtual Device:

internetcheck = Net.FHttp("wwweeee")

response = internetcheck:GET("/")

if response >0 then

fibaro:setGlobal("InternetOK", "1")

else

fibaro:setGlobal("InternetOK", "0")

end

In my mind this should set the Global "InternetOK" to 0 since "wwweeeee" is not a valid host (similar to when a valid host cannot be reached). Instead it is setting it to 1 anyway...

Any hint?

Thanks a lot

Riccardo

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

rcanetta, try that:

Please login or register to see this code.

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

Link to comment
Share on other sites

  • 0
  • Inquirer
  • rcanetta, try that:

    Please login or register to see this code.

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    Wow, fantastic, it works!!!

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" /> My neighbor will be very happy as well

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    Thanks, br

    Riccardo

    Link to comment
    Share on other sites

    • 0

    Hello to all ....

    I'm a newby of LUA , and i really don't know where I can found any documentation about LUA.

    This script is o good starting point for my .....but I want to know if there is any other test that can be done ?

    I've some device that need to be monitored, but not all have a web server that can be tested.

    Some device can be tested via snmp and some other can only be tested with ping.

    Can someone help me ?

    Link to comment
    Share on other sites

    • 0

    candrea77, to ping your device you can try my script here :

    Please login or register to see this link.

    i think Simple Network Management (SNMP) is not accessible in Fibaro LUA, LuaSNMP is not a part of HC2. (look at

    Please login or register to see this link.

    )

    rcanetta, Your are welcome

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" /> and my regards to your neighbor

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Best regards.

    Link to comment
    Share on other sites

    • 0

    If I understand well the code it's check if the internet connection is done or not. But how do you restart ADSL router???

    Link to comment
    Share on other sites

    • 0

    lolomail, Instead of changing the value of the global variable you can control a wall plug for example, turn off the wallplug, wait 60 secondes and turn on... or you can do the same with a scene triggered by the global value...

    Link to comment
    Share on other sites

    • 0

    Ok will try to do that as soon as I will have my wall plug

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    [ Added: 2013-05-29, 18:32 ]

    Krikroff, I tried your code and I have the following error message:

    [ERROR] 18:31:39: line 6: attempt to call method 'log' (a nil value)

    Do you know from where this is coming??? Thx

    Link to comment
    Share on other sites

    • 0
    Ok will try to do that as soon as I will have my wall plug

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    [ Added: 2013-05-29, 18:32 ]

    Krikroff, I tried your code and I have the following error message:

    [ERROR] 18:31:39: line 6: attempt to call method 'log' (a nil value)

    Do you know from where this is coming??? Thx

    I replaced all references of fibaro:log( with fibaro:debug(

    However i'm now greeted with another error:

    [ERROR] 01:00:36: line 11: attempt to index global 'Net' (a nil value)

    I have no knowledge of the Net library.... is there something special needed to make it work ?

    Link to comment
    Share on other sites

    • 0
    Guest deraaij

    Hi,

    Are using a scene? The Net library currently only works in virtual devices.

    Link to comment
    Share on other sites

    • 0

    Hi,

    If i all understand, i automate with a scene and a timer ?

    somebody has a exemple ?

    somethink like that ?

    Please login or register to see this code.

    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.

     Share

    ×
    ×
    • Create New...