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

Coffee machine turnoff by power and timer


Question

Posted

Hi,

I was thinking of a scene that is triggered upon power consumption in a wall plug.

I got one connected to my coffemachine and was thinking that if the power consumption goes above threshold value a timer would start and check the power once more after 1h.

If its still on... its forgotten, send push and turn it off... But I'm stuck!

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" />

--[[

%% properties

69 valueSensor

%% globals

--]]

local currentDate = os.date("*t");

local power = fibaro:getValue(69, "valueSensor")

local threshold = 50 -- Threshold in watt

if (tonumber(power) > threshold) then

fibaro:debug("HC2 Coffee script started: " .. os.date());

fibaro:debug("Consumption="..power.." Watt")

fibaro:debug("Coffee Machine is ON") -- lite debug text

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" />

end

... Timer to check again after 1h?

fibaro:call(69, "TurnOff")

fibaro:debug("Send push message")

fibaro:call(47, "sendPush", "Coffe Machine automatically turned of at: " .. string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min));

4 answers to this question

Recommended Posts

  • 0
Posted

Sorry to hijack your question but I'm on a crusade to find design patterns for common task using setTimer instead of sleep (and global variables) so I thought your example was a good exercise

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" /> Disclaimer: undeployed code that may contain bugs.

Please login or register to see this code.

This could be such a pattern. Drawback is that it uses polling instead of events so it could miss the machine being turned off and on within the polling interval. Also a bit unsure about the 'power' property still being ok in v4.

The holy grail now is to find a mechanism (loophole?) to connect a triggered scene with an already scheduled task... then we can get tasks (closure with states) that also reacts to device events

Please login or register to see this image.

/emoticons/default_icon_razz.gif" alt=":-P" />

Edit: dang! The scene can be triggered many times while the coffee machine is on if the power varies. In the sleep model one could always synchronize on the count of how many instances of the scene that was currently running... not a pattern yet

Please login or register to see this image.

/emoticons/default_icon_confused.gif" alt=":-?" />

  • 0
Posted

KristianO, My power monitoring is now borked but I was previously doing that with a scene.

Essentially if my hose pump was using more than 50w for more than 20 mins then I shut it down and sent an email.

Please login or register to see this image.

  • 0
Posted

Here you can find my lua that i use to my coffiemaker, it doesent send push but it do the work. you can update with push if you want.

ps are you using ver4.xxx you must change "valueSensor" to power

Please login or register to see this link.

  • 0
  • Inquirer
  • Posted

    AtomicGrog: I think the problem with this is that when i actually do remember to turn it of, the code will still turn off the plug too. I dont want that.

    SonnyBoy: I will test you code but it seems like to have the right solution. Nice! Thanks!

    Jgab: No problem at all! Does this asyncronos "wait" mean that it will not stay in the scene?

    Since i dont really understand the difference with the old sleep and new timeout

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