Use Sonoff Basic w/ TASMOTA for simulating Keurig Power Button?

757 views
Skip to first unread message

Michael Ingraham

unread,
Jul 4, 2018, 1:07:21 PM7/4/18
to SonoffUsers
I want to be able to integrate our Keurig machine into our home automation scheme. I want to control when the machine comes on based on our daily schedule. On weekdays it needs to pre-heat at an earlier time than on weekends. I want to turn it off when we are all gone to work in the morning. Finally, I don't want the coffee maker to come on at all when we are traveling and are not at home.

Our Keurig has an Auto-on/Auto-off capability... but this is a fixed time of day setting. Also, when we lose power in the house, the clock has to be set and the settings "stepped through" in order to reprogram the machine for the auto on/off to function again.

I can use a Sonoff Basic to control mains power to the Keurig. This would allow me to turn power on in the morning at the desired time for the particular days of the week. I can also turn power off based on when we leave the house or after a certain amount of time. I can also keep it from turning on at all when we're away from home. This addresses most of the desired features except for one big problem... the power button on the Keurig!

Keurig machines use a momentary switch to toggle the device on and off. This prevents me from just "shorting" the power button on the Keurig in order to then control the coffee maker completely with an external smart switch.

I have not been able to find any documentation on the electricals of consumer Keurig machines. I believe that on my machine (Keurig K70) the which is a low voltage switch. The wires connected to the switch are quite small gauge. I was thinking that I could use one of the GPIO pins on the Sonoff to emulate the momentary action of the switch.

A couple of outstanding questions:
  • Can I use one of the Sonoff GPIO pins (01?, 14?) as described?
  • Assuming a Sonoff is an option and that I would load TASMOTA firmware on it, can TASMOTA control these other GPIO pins (i.e., not just GPIO12)? More specifically, it via MQTT?
I actually have one issue regarding having the same low voltage GND reference between the two devices (Keurig & Sonoff) in order to drive the Keurig "switch" properly. The nagging feeling I have is that this makes my concept a non-starter. Thoughts? Alternatives? I'm just conceptualizing so if there's an altogether different approach, I'm all ears. 

Thanks for any and all of your insights!

Mike

P.S. Let me address the Keurig vs. old fashioned coffee maker responses which this kind of topic inevitably garners. My wife and I have considerably different coffee palettes so a one pot fits all is not going to cut it. This is the reason we went to Keurig single cup solution oh so long ago. In fact, every once in a blue moon, we even get a wild hair and opt for a cup of tea. So an old fashioned Mr. Coffee is not the solution to our need.

P.P.S. Also, to avoid the Keurig K-cup environmental impact debate, can I say that we minimize this by using the Keurig adapter that lets use use our own coffee and not always use  K-cup. I confess though that we occasionally use K-cups (particularly for the tea)... so I'm not guilt free. I religiously recycle (ask my wife!) as penance ;-)

Philip Knowles

unread,
Jul 4, 2018, 2:50:07 PM7/4/18
to Michael Ingraham, SonoffUsers

You may be better buying an HW-655 (if you search for ESP8266 relay you'll find them) and putting it into a small box and powering it with a USB adaptor. They are available on eBay for about £5. Important thing is that has a volt-free relay contact. If you flash it with Tasmota you can set it to give a 'blink' output. You can also programme rules to switch it on/off at different times. If you want to go the whole hog yoy could use openHAB and bluetooth tags to automatically switch off when everyone has left the house

Regards

Phil


--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Ingraham

unread,
Jul 4, 2018, 4:48:26 PM7/4/18
to SonoffUsers
Basically what I'm trying to do by using the Sonoff as a low voltage relay, i.e., this device.

I am using openHAB, so the things like scheduling, home/away, etc. are already things I am doing w/ other devices in our home. Thus the only missing bit is controlling the turning on/off of the Keurig.

"If you flash it with Tasmota" - apparently a big if. The information I've found after an hour or so of Internet research is that there are two aspects to this. One is interfacing to the ESP8266 and the other is having that module control the relay board. It appears that the HW-655 requires a 4-byte sequence of codes sent to it serially at 9600 baud:
  • Close: A0/01/01/A2
  • Open:  A0/01/00/A1

  1. I'm not sure how to put these ESP-01 modules that plug into the relay board into programming mode nor how to connect it so that I can upload TASMOTA to it.
  2. I'm not sure that even if I succeed with #1 that I can send the control sequences to the relay through openHAB, via MQTT or otherwise.

If this involves a different openHAB binding... I've had a steep learning curve. I've spent tons of hours over the last three months with MQTT, OwnTracks, openHAB Items, Rules, Sitemaps, etc. If you have used the HW-655 with openHAB... I'm all ears and willing to follow your lead ;-)

The Sonoff is attractive to me is that it's a known entity, I've finally figured out how to flash it, control if through openHAB,... and it has a case. Having said all of that, if the Sonoff can't be used for this application, then all of those points a moot - a different solution, that actually works, is necessary.

Cheers!

Mike
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Michael Ingraham

unread,
Jul 31, 2018, 12:43:56 AM7/31/18
to SonoffUsers
My Yunshan Relay Module arrived today (it took over three weeks even though it left China on a plane!). I flashed TASMOTA on it and selected the module type as Yunshan Relay. Everything appears to be fully functional.

Question: Does TASMOTA have an "inching" mode? That is, is there a command or configuration that when the command is sent to the device, it turns it on and then after a short delay it turns it off. If not, I can implement this is a TASMOTA rule easy enough. But if there's already a setting built in, it would be cleaner to use that instead.

Regards.

Mike

Philip Knowles

unread,
Jul 31, 2018, 1:10:53 AM7/31/18
to Michael Ingraham, SonoffUsers

Yes it's called Blink mode. Set BlinkCount 1, set BlinkTime 1 (x 100ms). Power 3 (instead of Power 1) to make it 'blink'.

Regards

Phil K


To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.

Michael Ingraham

unread,
Jul 31, 2018, 2:05:51 AM7/31/18
to SonoffUsers
Philip,

Missed blink. Was about to use PulseTime.

TASMOTA - SO many features!

Thanks for pointing me in the right direction!

Mike

Phil

unread,
Jul 31, 2018, 9:17:43 AM7/31/18
to SonoffUsers
yes  i would also suggest pulsetime to be the option to look at for a limited on time (auto OFF) when switched on.

Michael Ingraham

unread,
Jul 31, 2018, 5:21:46 PM7/31/18
to SonoffUsers
Happy to report that I've completed this project. A few tasks to tidy up the installation wiring, but our Keurig coffee maker has been assimilated... into openHAB ;-)

Philip Knowles

unread,
Jul 31, 2018, 6:00:52 PM7/31/18
to Michael Ingraham, SonoffUsers

Well done!
My next project is replacing thermostatic radiator valves with the Yushan modules you found and solenoid valves. Works out at <£10 per radiator. Waiting for the valves to arrive from Aliexpress

Regards

Phil K


To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.

Phil

unread,
Aug 1, 2018, 9:38:21 AM8/1/18
to SonoffUsers
that sounds interesting  got any links??  

Philip Knowles

unread,
Aug 1, 2018, 10:46:56 AM8/1/18
to Phil, SonoffUsers

Here is the solenoid valve

https://www.aliexpress.com/item/2W025-08-New-DC-12V-Electric-Solenoid-Valve-1-4-for-Brass-Air-Water-Gas-Diesel/1000003943096.html?spm=a2g0s.9042311.0.0.7edb4c4dIkzVA7

My CH uses microbore (8mm) copper tubing so I'm fairly sure the 2.5mm orifice will be OK. I think there’s a 4mm one available too.

 

Relay module is here

https://www.ebay.co.uk/itm/DC-7-30V-5V-220V-ESP8266-WIFI-Relay-Module-10A-ESP-12F-Network-Relay-Module/292519462331?ssPageName=STRK%3AMEBIDX%3AIT&var=591348897492&_trksid=p2057872.m2749.l2649

 

Will add a DS18B20 (hopefully) and a wall wart 12v psu (got a few lying around so don’t need to buy them)

 

Will then connect to openHAB which already controls the pump and hot water.

 

Regards

 

Phil K

 

 

 

Sent from Mail for Windows 10

Michael Ingraham

unread,
Aug 1, 2018, 11:41:31 AM8/1/18
to sonof...@googlegroups.com
I don't have a page where I can post this, but I did make some notes.

Hardware
  • Yunshan ESP8266 Relay Module
  • A smart switch to control the AC power to the Keurig. I used a TP-Link HS-105 I had laying around primarily for convenience because it is a three prong (US) device. It has openHAB integration out of the box. (I use lots of Sonoff stuff too. The reason I had this "spare" HS-105 is because I decommissioned it in lieu of a Sonoff Basic)
  • 7-30 VDC AC Power Adaptor. I'm using a 9VDC adaptor. A 5VDC phone charging wall-wort does not provide sufficient voltage.

Flashing the device
 
  • Connect input voltage leads.
    • Line (A)
    • GND (B)
  • To flash the device, the jumper on P3 "Boot" must be shorted and remains shorted throughout the upload. For regular operation, the P3 jumper must be removed.
  • Flash  TASMOTA Firmware (I'm using 6.1.1b at this time).
  • Select "Yunshan Relay" as the module type.
  • Console setup:
    • Backlog LedPower 0; LedState 0
      Disable the Power LED (blue) indicator. The blue LED will be used for Wi-Fi status only. A separate red LED indicates the relay state.
    • Backlog PulseTime 2;BlinkCount 1; BlinkTime 2
    • FriendlyName Keurig Toggle Yunshan
Operational Connections
  • Connect Input power (see above)
  • Solder extensions (retain the Keurig switch connection for manual operation)   from the Keurig switch leads (red & black) to protrude next to the AC power cord out the rear of the coffee maker.
    • Connect the black to terminal (D) - Common
    • Connect the red to terminal (C) - NO
According to the article the NC contact is (C). For my Yunshan unit, this must be the NO contact. I had tested the external leads I added to the Keurig. With the Keurig plugged in, shorting the leads (i.e., closing the circuit) caused the Keurig to toggle on/off. Using terminal (E) on the Yunshan caused the Keurig to be on anytime the machine was powered (connected to an outlet). With terminal (E) connected, I could not toggle the Keurig on and off using the Yunshan.

Operation
  • Power 3 (Blink)

Home Automation
  • Knowing what state the Keurig is in (on or off) is tricky because the on/off switch is a momentary switch. The state of the Yunshan does not reflect the state of the Keurig. 
  • I have this set up in openHAB. The rules logic toggles the Yunshan to turn the Keurig on. The logic also controls the power switch (HS-105) to turn the Keurig off. Turning off power ensures that the Keurig is off.
  • To ensure that one can manually click the physical switch on the Keurig to turn it on or off, turning off the power (HS-105) is only momentary - I turn it off but come right back and turn power back on.
  • I have two rules: one to turn it on automatically in the mornings (with a delay timer to turn it off later), and another rule to respond to the UI/Google Assistant command (which also has a delay timer to turn it off automatically later). Because controlling the Keurig requires controlling two devices, I have the UI set up as a virtual switch so that when it is turned on or off, the rule takes care of the actions necessary on the Yunshan and the power (HS-105).
The rules look at the presence information I have set up with OwnTracks. If we're not home, it won't turn on the Keurig in the morning... which is the entire reason I did this project. The Keurig has a scheduling feature... but when we left town for a few days I had to unplug it to keep it from turning on. AND, when we returned, I'd have to re-program it to set the schedule. I now can just forget about this because OwnTracks will send our location as we pull away from the house and openHAB takes care of the rest.

openHAB Setup

Items
Switch      VT_coffeeMaker
           "Coffee Maker"
           [Switchable]

//Switches
Switch      keurig_toggle
           "Keurig Coffee Maker Switch"
           { mqtt="
                   >[broker:cmnd/keurig_toggle/POWER:command:*:3],
                   <[broker:stat/keurig_toggle/POWER:state:default]
                  " }

//Plugs
Switch      coffeeMaker
           "Coffee Maker Power"

Sitemap
Switch item=VT_coffeeMaker

Rules
var Timer CoffeeMakerDelayTimer = null

rule "Morning Coffee"
   when
       Time cron "0 15 7 ? * MON-FRI" or
       Time cron "0 30 7 ? * SAT,SUN"
   then
        CoffeeMakerDelayTimer?.cancel

        // Only turn the coffee maker on if we're home
       if (GP_presence_home.state == ON)
       {
           if (VT_coffeeMaker.state == OFF)
               postUpdate(VT_coffeeMaker, ON)

            if (coffeeMaker.state == OFF)
           {
               coffeeMaker.sendCommand(ON)
               createTimer(now.plusSeconds(2)) [ |
                   keurig_toggle.sendCommand(ON)
               ]
           }
           else
           {
               sendCommand(keurig_toggle, ON)
           }

            // Set a delay timer to turn the coffee maker off
           CoffeeMakerDelayTimer = createTimer(now.plusMinutes(90)) [ |
               coffeeMaker.sendCommand(OFF)
               createTimer(now.plusSeconds(1)) [ coffeeMaker.sendCommand(ON) ]
           ]
       }
       else
       {
           if (coffeeMaker.state == ON)
           {
               if (VT_coffeeMaker.state == ON)
                   postUpdate(VT_coffeeMaker, OFF)

                coffeeMaker.sendCommand(OFF)
               createTimer(now.plusSeconds(1)) [ coffeeMaker.sendCommand(ON) ]
           }
       }
end

rule "Control Coffee Maker"
   when
       Item VT_coffeeMaker received command
   then
        CoffeeMakerDelayTimer?.cancel

        // Only turn the coffee maker on if we're home
       if  (   (GP_presence_home.state == ON) &&
               (VT_coffeeMaker.state == ON)
           )
       {
           if (coffeeMaker.state == OFF)
           {
               coffeeMaker.sendCommand(ON)
               createTimer(now.plusSeconds(2)) [ |
                   keurig_toggle.sendCommand(ON)
               ]
           }
           else
           {
               keurig_toggle.sendCommand(ON)
           }

            // Set a delay timer to turn the coffee maker off
           CoffeeMakerDelayTimer = createTimer(now.plusMinutes(30)) [ |
               coffeeMaker.sendCommand(OFF)
               createTimer(now.plusSeconds(1)) [ coffeeMaker.sendCommand(ON) ]
           ]
       }
       else
       {
           // Make sure the coffee maker is off but leave the power on

            if (coffeeMaker.state == ON)
           {
               coffeeMaker.sendCommand(OFF)
               createTimer(now.plusSeconds(1)) [ coffeeMaker.sendCommand(ON) ]
           }
           else
           {
               coffeeMaker.sendCommand(ON)
           }

            if (VT_coffeeMaker.state == ON)
               postUpdate(VT_coffeeMaker, OFF)
       }
end


 Happy hacking!

Mike

Phil

unread,
Aug 1, 2018, 8:39:37 PM8/1/18
to SonoffUsers
Thanks Phil, I actually have a a few 1/2" valves left over from some brewery automation, tho they do require a minimum back pressure which is what relegated them to the spares box as the system is gravity fed. I dont know if the central heating pump would generate the 0.8kpa??  iirc needed  but i will check if one could fit in place of either of the current valve ends with the limited play hard copper feed tubes provide. 

I going to have to re read the thread for the reasons the Yunshan dc board is favoured over the sonoff sv??  

can i ask which end are you fitting them, the stop end or the restrictive valve end?   - Perhaps I should start a new central heating thread as i have more questions..
Reply all
Reply to author
Forward
0 new messages