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

Turn off WallPlug if watt is over 50w in 30 min


sonnyboy

Question

I wonder i someone can help me look in to this, i have tried and tried.

We have a Moccamaster and sometimes we forgot to turn it off, burnd coffee don't smell good

Please login or register to see this image.

/emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

So i made a little luacode that i thought would help me out, it helps a little to much.

My problem is that the wallplug turns off after 30 minutes even when i don't forgot to turn of the coffe machine.

Please login or register to see this code.

Link to comment
Share on other sites

Recommended Posts

  • 0
Another way is add "if" (to check again) before you turn off device.

Please login or register to see this code.

Yes, but this will keep the instance open for the entire 30 minutes. Therefore, if you turn off the coffee maker and then turn it on again within the 30 minutes, the scene will still think that the machine have been on for the entire 30 minutes and therefore turn off the plug - even though it isn't supposed to. Therefore, you need to introduce regular status checks and then abort the scene if the status changes. That way, the scene will abort as soon as you turn off the machine and restart next time it is turned on. So you can make more than one can of coffee every half hour.

[ Added: 2014-09-26, 09:41 ]

Dalle1985, sorry im not very sure. I always thought it will only trigger when this line is available.

local startSource = fibaro:getSourceTrigger();

if .....

startSource["type"] == "other"

)

No, as long as it is mentioned in the properties it will work. the fibaro:getSourceTrigger() will just return an array with information on what triggered the scene to run:

Please login or register to see this link.

That way, you can have one scene with multiple triggers and different actions for each trigger, by reading the array.

Link to comment
Share on other sites

  • 0

You are asking the code to check if the TEXT "50" is larger than another text. How can one text be higher than another?

Please login or register to see this code.

This won't do... It will always return true and therefore turn off the plug

You need to use numbers, i.e.:

Please login or register to see this code.

This should do it for you...

Link to comment
Share on other sites

  • 0
  • Inquirer
  • My code does work, and so do yours, (i changed to yours to make it right) but i think my problem is that when the local timer starts, it wont put in new watt values from the plug, and because of that the plug goes off. Thats my teori, and how do i get round that if that is my problem?

    Link to comment
    Share on other sites

    • 0

    Yes, what your code does right now, is to say, if the value is >50 right now, it will turn off the device in 30 minutes - no matter what happens. I thought that was the purpose...

    So you need to run a loop instead. So the loop sleeps for i.e. 10 seconds, then checks the value. If the value has dropped below 50, it aborts the code:

    Please login or register to see this code.

    This isn't tested, but it should work (i cant remember if lua does countdown--, therefore countdown=countdown-1

    Link to comment
    Share on other sites

    • 0

    Either way sonnyboy code does not have any trigger factor. How can the scene start?

    Correct me if I'm wrong.

    And perhaps what he means is he wants to check if coffee maker is on then turn off.

    Link to comment
    Share on other sites

    • 0
    Either way sonnyboy code does not have any trigger factor. How can the scene start?

    Correct me if I'm wrong.

    And perhaps what he means is he wants to check if coffee maker is on then turn off.

    It triggers on change of valueSensor on id 35?!

    Link to comment
    Share on other sites

    • 0

    Dalle1985, sorry im not very sure. I always thought it will only trigger when this line is available.

    local startSource = fibaro:getSourceTrigger();

    if .....

    startSource["type"] == "other"

    )

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @MalvinYNJ

    It works my way, ill put in a little screen dump.

    [ Added: 2014-09-26, 08:21 ]

    @Dalle1985

    I will test your code when i get home tonight.

    Tanks

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I tried with blocks and never got it to work, then i tried do it in lua but only got half the way, thats why,

    Link to comment
    Share on other sites

    • 0

    Hmm ok well GL with it then.

    My checks are slightly different, I'm looking to see when a TV centre is switched to standby and then I switch the power off if it remains unused for more than 20 mins.

    Seems reliable, albeit I do two tests... one for W < 40 and the other for W > 0 (I found that at times the power meter aspects of my switched glitch and show 0)

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Dalle1985

    This is exactly what i want, works like it should.

    Tanks so much for the help, i had ever come up with this solution

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Link to comment
    Share on other sites

    • 0
    Hmm ok well GL with it then.

    My checks are slightly different, I'm looking to see when a TV centre is switched to standby and then I switch the power off if it remains unused for more than 20 mins.

    Seems reliable, albeit I do two tests... one for W < 40 and the other for W > 0 (I found that at times the power meter aspects of my switched glitch and show 0)

    I'm trying to do almost the same.

    I tried blocks and said, when tv w>5 turn on sub, media player and so on.

    And another screen, when the tv w<5 turn off the things.

    But nothing ever happens.

    Link to comment
    Share on other sites

    • 0

    Ahh... Convert to lua and try this code:

    Please login or register to see this code.

    Where XX is the id of the tv and YY is the device you want to switch on/off. You can add more devices by repeating the three lines

    Please login or register to see this code.

    And

    Please login or register to see this code.

    To get more devices in. Just remember to put them inbetween the start and end markers for the devices

    Link to comment
    Share on other sites

    • 0

    Create a new scene, go to the advanced tab, press save as Lua and then input the script, remember to push the disc icon in the bar on the right hand side of the page when you are done to save it again. Do this every time you've changed something before moving away from the editor page...

    Link to comment
    Share on other sites

    • 0
    Create a new scene, go to the advanced tab, press save as Lua and then input the script, remember to push the disc icon in the bar on the right hand side of the page when you are done to save it again. Do this every time you've changed something before moving away from the editor page...

    just as i tried. but nothing is saved. not even when i just make a standard scene with no ekstra.

    When i try to edit a scene and press Start after it, i get this error:

    [ERROR] 21:19:22: LUA error: /opt/fibaro/scenes/4.lua:11: attempt to perform arithmetic on local 'deviceLastModification0' (a nil value)

    Link to comment
    Share on other sites

    • 0

    Looks lige this:

    --[[

    %% properties

    28 valueSensor

    %% globals

    ]]--

    if tonumber(fibaro:getValue(28, "valueSensor")) > 5 then -- replace XX with device id for trigger

    -- start of devices to switch on

    -- replace YY with id of device you want to switch on when XX is above 5W

    if tonumber(fibaro:getValue(23, "value"))==0 then

    fibaro:call(23, "turnOn")

    end

    if tonumber(fibaro:getValue(26, "value"))==0 then

    fibaro:call(26, "turnOn")

    end

    if tonumber(fibaro:getValue(29, "value"))==0 then

    fibaro:call(29, "turnOn")

    end

    -- end of devices to switch on

    end

    if tonumber(fibaro:getValue(XX, "valueSensor")) < 5 then

    -- start of devices to switch off

    -- replace YY with device you want to switch off when XX is below 5W

    if tonumber(fibaro:getValue(23, "value"))==1 then

    fibaro:call(23, "turnOff")

    end

    if tonumber(fibaro:getValue(26, "value"))==1 then

    fibaro:call(26, "turnOff")

    end

    if tonumber(fibaro:getValue(29, "value"))==1 then

    fibaro:call(29, "turnOff")

    end

    -- end of devices to switch off

    end

    [ Added: 2014-10-15, 11:08 ]

    Now i get this error, and the config looks like this:

    Error:Line 8: fibaro attempt to compare number with nil.

    Line 8 is highlightet with BOLD.

    --[[

    %% autostart

    %% properties

    28 valueSensor

    %% globals

    ]]--

    if tonumber(fibaro:getValue(28, "valueSensor")) > 5

    then

    -- start of devices to switch on

    if tonumber(fibaro:getValue(23, "value"))==0

    then

    fibaro:call(23, "turnOn")

    end

    if tonumber(fibaro:getValue(26, "value"))==0

    then

    fibaro:call(26, "turnOn")

    end

    if tonumber(fibaro:getValue(29, "value"))==0

    then

    fibaro:call(29, "turnOn")

    end

    -- end of devices to switch on

    end

    if tonumber(fibaro:getValue(XX, "valueSensor")) < 5

    then

    -- start of devices to switch off

    if tonumber(fibaro:getValue(23, "value"))==1

    then

    fibaro:call(23, "turnOff")

    end

    if tonumber(fibaro:getValue(26, "value"))==1

    then

    fibaro:call(26, "turnOff")

    end

    if tonumber(fibaro:getValue(29, "value"))==1

    then

    fibaro:call(29, "turnOff")

    end

    -- end of devices to switch off

    end

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