# Smart Seconds Timer?



## Tihsho (Sep 21, 2009)

Over the years I've migrated a lot of my mechanical timers to digital, and more recently to smart outlets. One thing I'd like to migrate is a DIY MistKing style misting system that I use on my emersed plant grow out systems. So far I've only been able to control the pump power with a digital timer. I'd like to get rid of it and tie it into my home voice automation so I don't have to dig my arm behind the rack to manually trigger the timer. It's just annoying to have to find the buttons when new plants get put in or humidity drops after doing maintenance in the tanks. 

I know I can DIY a solution with a Raspberry Pi and some relays, but I'd just like to get something off the shelf for once.


----------



## fishingguy12345 (Apr 7, 2019)

Is there a reason you can't have the timer in a different location? 

The Mistking digital seconds timer has a cord that lets you place the controller 3-4' away from the pump. This might be an option for your system?


----------



## minorhero (Apr 24, 2020)

Tihsho said:


> Over the years I've migrated a lot of my mechanical timers to digital, and more recently to smart outlets. One thing I'd like to migrate is a DIY MistKing style misting system that I use on my emersed plant grow out systems. So far I've only been able to control the pump power with a digital timer. I'd like to get rid of it and tie it into my home voice automation so I don't have to dig my arm behind the rack to manually trigger the timer. It's just annoying to have to find the buttons when new plants get put in or humidity drops after doing maintenance in the tanks.
> 
> I know I can DIY a solution with a Raspberry Pi and some relays, but I'd just like to get something off the shelf for once.


I would be interested in this as well but I'm not confident it exists. There are lots of cheap seconds timer out there but ones that work with wifi? None I have seen and I looked quite a bit when putting up my tank 6 or so months ago. One problem is that the amazon echo app (not sure about google) does not support seconds, only minutes so anyone building a timer that is compatible will probably not include that functionality, especially since people misting vivarium's are essentially the only people who want this functionality. My 'solution' would be to put your timer closer to you so you don't need to reach behind the rack. Use an extension cord to bring it out from the wall. Not great I know but I don't think there is a way of doing it elegantly where you can tell your echo or google to "turn on misters" and they turn on for exactly 10 seconds and then turn off.


----------



## Tihsho (Sep 21, 2009)

fishingguy12345 said:


> Is there a reason you can't have the timer in a different location?
> 
> The Mistking digital seconds timer has a cord that lets you place the controller 3-4' away from the pump. This might be an option for your system?


Relocating the timer isn't really much of an option, I have my power strip mounted in a way to be away from any source of water as well as in a way that I can access it without my rack being further away from the wall than it is. 

Yep I have one of these on another rack and know how it works. Again, I'm looking for a '*smart*' device not a standalone controller as that's what I already have. Plus, the way that this controller physically interfaces with the pump will require a DIY solution which I'm holding off on. Being that this lacks a the smart WiFi connection, this is at the bottom of my list of options.



minorhero said:


> I would be interested in this as well but I'm not confident it exists. There are lots of cheap seconds timer out there but ones that work with wifi? None I have seen and I looked quite a bit when putting up my tank 6 or so months ago. One problem is that the amazon echo app (not sure about google) does not support seconds, only minutes so anyone building a timer that is compatible will probably not include that functionality, especially since people misting vivarium's are essentially the only people who want this functionality. My 'solution' would be to put your timer closer to you so you don't need to reach behind the rack. Use an extension cord to bring it out from the wall. Not great I know but I don't think there is a way of doing it elegantly where you can tell your echo or google to "turn on misters" and they turn on for exactly 10 seconds and then turn off.


In theory all off the shelf solutions will work in seconds, the problem is exactly what you mentioned; the software. I run a handful of Amazon Echo's throughout the house as they tie into my lighting (lamps and aquariums), home security system, HVAC, and prevent the girlfriend from shouting for me when she can't find me and I don't have my phone on me, yay intercom functions. 

From what I can tell, there are a lot of reasons seconds functions would be ideal even outside of misting solutions, but people are investing into industrial controllers that happen to tie into Alexa for their projects. I don't see the point of sinking hundreds of dollars into a single plug that requires an additional hub just to make this work (as some garage door and driveway gate motor projects require.) I just wish the Amazon folks would realize that some people need timed functions that were not "turn on at 8:00AM and turn off at 8:01AM" and would put a timer function that is "at 8:00AM turn on device for HH:MM:SS duration."

As for relocating the timer... As I mentioned above in regards to the previous post, it's not exactly a simple thing to do. I have the rack setup in a nook that is under some stairs where it fits perfectly the way it is. In order to relocate the timer, I'd need to either mount it under a shelf which would in turn expose it to possibly getting dripped on if there is a leak, or I'd have to pull the rack further away from the wall and then it won't 'fit' in the place I have it. Luckily the nook is in my fishroom that happens to be an additional utility room, problem is I'm limited by space and I'm trying to optimize what I've got for the projects I need to house in there.


----------



## Shrimply (Sep 20, 2020)

I might be missing something, but I think you could achieve this with any Alexa enabled smart plug.

Alexa routines appear to be able to handle seconds.

So can you not have a routine that runs when you need it to (you might have to set up separate routines if you want it to runs multiple times a day), turns your device on, waits for x number of seconds and then turns it off again?


----------



## Tihsho (Sep 21, 2009)

Shrimply said:


> I might be missing something, but I think you could achieve this with any Alexa enabled smart plug.
> 
> Alexa routines appear to be able to handle seconds.
> 
> So can you not have a routine that runs when you need it to (you might have to set up separate routines if you want it to runs multiple times a day), turns your device on, waits for x number of seconds and then turns it off again?


The Alexa app does not allow you to set a 'timed' schedule by hours:minutes:seconds, it only allows you to set like the example below:

*Start
08:00AM

Stop
08:01AM*

There isn't a 'seconds' section in the code. I've reached out to the Alexa development group about this and am waiting on a reply. I wish there was a way to setup a 'timed' routine in the software so I can setup the routine for "30 seconds" and have that routine be tied to kick off at 8:00AM and 4:00PM.


----------



## Shrimply (Sep 20, 2020)

Tihsho said:


> The Alexa app does not allow you to set a 'timed' schedule by hours:minutes:seconds, it only allows you to set like the example below:
> 
> *Start
> 08:00AM
> ...


Ahh, but what I'm trying to say is that you can have a wait period of 30 seconds within a routine. So you can set a scheduled routine to run every day at 8.00 AM which turns on your device, waits 30 seconds, and then turns your device off. And set another routine for 4.00 PM. Obviously you can also give the routine a name so it can also happen whenever you request it. 

So unless you are missing the WAIT argument within routines I think it is possible, although not exactly in the way you imagine setting up. I've just tested this using a smart plug and turned on a light for 5 seconds at the scheduled time. It's unlikely we have a feature in the UK that you don't have in the US.

https://1drv.ms/u/s!AqKNJqaDFP_rhOEcH_8R6SgO-skBdA?e=ZELkRw

Or is that not a suitable workaround for a reason I don't understand?


----------



## minorhero (Apr 24, 2020)

Shrimply said:


> Ahh, but what I'm trying to say is that you can have a wait period of 30 seconds within a routine. So you can set a scheduled routine to run every day at 8.00 AM which turns on your device, waits 30 seconds, and then turns your device off. And set another routine for 4.00 PM. Obviously you can also give the routine a name so it can also happen whenever you request it.
> 
> So unless you are missing the WAIT argument within routines I think it is possible, although not exactly in the way you imagine setting up. I've just tested this using a smart plug and turned on a light for 5 seconds at the scheduled time. It's unlikely we have a feature in the UK that you don't have in the US.
> 
> ...


I had heard of the wait function (relatively recent addition) but hadn't put it together to have a wait function to turn off the unit! What a great idea! Thank you, this I think solves the issue.


----------



## Tihsho (Sep 21, 2009)

Shrimply said:


> Ahh, but what I'm trying to say is that you can have a wait period of 30 seconds within a routine. So you can set a scheduled routine to run every day at 8.00 AM which turns on your device, waits 30 seconds, and then turns your device off. And set another routine for 4.00 PM. Obviously you can also give the routine a name so it can also happen whenever you request it.
> 
> So unless you are missing the WAIT argument within routines I think it is possible, although not exactly in the way you imagine setting up. I've just tested this using a smart plug and turned on a light for 5 seconds at the scheduled time. It's unlikely we have a feature in the UK that you don't have in the US.
> 
> ...


You sir just saved the day! I've been searching around Alexa forums for a bit now and not found a damn thing! This is exactly what I was after. Thanks again!


----------



## Shrimply (Sep 20, 2020)

I'm glad to be of assistance, I'm sure you will all repay me with lots of good frog related advice down the line


----------



## Tihsho (Sep 21, 2009)

I just wanted to update this as I've had my first failure with the Alexa WAIT function. Got a frantic call from the misses about the Misting System on my one display was running for over 10 minutes... Well poop. It was only supposed to kick on for 10 seconds which it had before. Oddly enough this happened when I wasn't home and on a rare on-site work visit. Previously it seemed fine for the past day and a half. Luckily I have cats who scream when something interests them. So between her noticing the viv being misted (well dribbled on since its a crappy Monsoon) and the constant reminder from screaming of cats who are excited about the vibrations of the pump made it clear there was a problem. I even checked the app remotely and the status was 'on' so I need to check out whats going on.

This might be a great function thats just buggy and requires a few failsafes to be setup. Going to have to look into either drilling a drain or keeping an eye on the false bottom water levels daily rather than in passing.


----------



## fishingguy12345 (Apr 7, 2019)

Tihsho said:


> Going to have to look into either drilling a drain or keeping an eye on the false bottom water levels daily rather than in passing.


I have drain holes drilled in all my vivariums and I still check the water level in the false bottoms every day anyways...


----------



## Shrimply (Sep 20, 2020)

Tihsho said:


> I just wanted to update this as I've had my first failure with the Alexa WAIT function.



Is it possible the plug dropped connection over the time it was supposed to receive the off action. I think that's the most likely reason.

You could set regular 'offs' throughout the day to somewhat limit the duration it ends up being switched on for.

Unfortunately without programming it yourself I don't think there is a really good solution. You really need to be able to check the connection to the plug, and if it isn't connected continue checking until you have a connection, and then tell the plug to turn off.


----------



## Tihsho (Sep 21, 2009)

The key thing thats the problem here is the cloud. If the Smart Plug was truly smart, it would have a micro controller setup in it with enough memory to cache configs. Ideally, I wish these devices would just refresh the cache x times per day to make sure that their schedules are synced to the application server. Right now these devices are just setup as 'dumb' end devices, they receive a trigger through WiFi to go on or off, not just run off of a set schedule internally. 

I'll debug this further when I get home. Worst case I'm just going to set up my own vivarum server on a Raspberry Pi and build my own smarter end nodes with either Raspberry Pi zeroes or a Arduino NodeMCU. I hate to reinvent the wheel on things like this, but when trying to replicate a micro environment consistency and reliability is key.


----------



## Shrimply (Sep 20, 2020)

I agree the cloud is problem. I think we've all been seduced by cloud-based solutions because the companies have made it so cheap and easy whereas there is far more benefits to local home automation ( that can be contacted over the internet only when necessary not by default)


I think coding it up on a Pi is the ultimate solution and at least you only have yourself to blame if something doesn't work! 

Take it to the extreme and fit a rain sensor in there and have it turn off the power when it's been activated for a set period of time, and a water level sensor to send you an alert when the water level in the false bottom gets too high


----------



## Tihsho (Sep 21, 2009)

I'm an engineer by trade, so over designing a product is easy for me to do... Problem is keeping it budget friendly without me going off the deep end with industrial parts. Trust me if a project like this were not limited by a budget I would have a beowulf cluster of machines data logging more information than necessary and running trends against the data. From there I'd work in logic to control lights and mistings to balance out temperature and humity on the fly, and look into a water reclamation process to take out water from the false bottom and particulate and chemically filter it and return the product RO/DI water to the misting reservoir and the effluent to be kicked to drain to my houses septic system... 

TLDR:
blah blah blah...


----------



## fishingguy12345 (Apr 7, 2019)

Tihsho said:


> TLDR:
> blah blah blah...



Lol! This made me chuckle


----------



## Reptihab (Sep 23, 2020)

Tihsho said:


> I'm an engineer by trade, so over designing a product is easy for me to do... Problem is keeping it budget friendly without me going off the deep end with industrial parts. Trust me if a project like this were not limited by a budget I would have a beowulf cluster of machines data logging more information than necessary and running trends against the data. From there I'd work in logic to control lights and mistings to balance out temperature and humity on the fly, and look into a water reclamation process to take out water from the false bottom and particulate and chemically filter it and return the product RO/DI water to the misting reservoir and the effluent to be kicked to drain to my houses septic system...
> 
> TLDR:
> blah blah blah...



Have you considered using a smart plug with a countdown time set for 1 min and then using a delay relay on the dc side of your pump to control seconds?


----------



## Tihsho (Sep 21, 2009)

Reptihab said:


> Have you considered using a smart plug with a countdown time set for 1 min and then using a delay relay on the dc side of your pump to control seconds?


I mean, that's an option, but I'd still consider it a band aid to a problem that shouldn't be so hard with what technology we have available today.


----------



## Reptihab (Sep 23, 2020)

I understand your point but for a smart plug to be able to react in seconds based on a wifi connection would be difficult to fine tune. With a relay system the smart plug would simply trigger it and the seconds can be accurately controlled.


----------



## Tihsho (Sep 21, 2009)

That's exactly why I'm working on my own smart plug. Something that has a brain in it that stores a config file rather than receives wireless triggers. The overall availability of maker parts on the market make this feasible with a little time and effort, the problem is I either have to put a lot of time into getting exactly what I want (tying it into Alexa) or just settling for a part of what I need it to do (a plug that has the ability to expand to work with Alexa later, but I can have schedules set, AND I can trigger remotely through a PC or phone app.)


----------



## Reptihab (Sep 23, 2020)

Qmv tdr12v2 12 vdc spdt


----------



## Tihsho (Sep 21, 2009)

Reptihab said:


> Qmv tdr12v2 12 vdc spdt


Yeah a very simple piece of hardware to accomplish the on/off in seconds, but it's missing the smart aspect. I'd like to be able to trigger some events manually without having to dig out the mechanical relay and change the settings on the pot to a longer duration. That or have to jumper power to the pump unit each time I'm looking to implement misting's greater than the preset on the TDR12V2.


----------



## Shrimply (Sep 20, 2020)

I've just been playing around with Home Assistant. It seem like it might be a good compromise between out-of-the-box solutions and a bit of tinkering.

It would allow local control of your smart plugs (down to the second), but it also keeps track of how long they are on or off for. So it seems like it would be easy to have protocols in place to turn off a smart plug if it had been running for x amount of time.

And obviously you can also tie it all in the Alexa if you wish.


----------



## Tihsho (Sep 21, 2009)

Shrimply said:


> I've just been playing around with Home Assistant. It seem like it might be a good compromise between out-of-the-box solutions and a bit of tinkering.
> 
> It would allow local control of your smart plugs (down to the second), but it also keeps track of how long they are on or off for. So it seems like it would be easy to have protocols in place to turn off a smart plug if it had been running for x amount of time.
> 
> And obviously you can also tie it all in the Alexa if you wish.


Yep further back in this thread we found a possible solution. It worked when applied to a lamp, when I configured a routine in the Alexa app and test played it. In it's actual application I've yet to get it to actually turn off after 30 seconds even with the *W*_*ait *_function configured as directed. 

As for Home Assistant, since I don't have Google Home setup I have not tested it. As I have everything currently tied through Alexa _cough_ _cough_ _devilapp_ _cough_ I'm not sure I want to go through migrating everything else. Depending how things go I may have to test it out though.


----------



## Shrimply (Sep 20, 2020)

Tihsho said:


> As for Home Assistant, since I don't have Google Home.


Sorry I mean this Home Assistant. Nothing to do with Google. It's a local based, open source home automation platform. I set mine up as a virtual machine on a Raspberry Pi.

The appeal would be that, depending on the plugs, it can control and poll them locally, eliminating a lot of the potential problems with using Alexa but allowing you to use the plugs you have already and not having to set up NodeMCUs and relay switches etc. Sort of a middle ground.


----------



## Tihsho (Sep 21, 2009)

Shrimply said:


> Sorry I mean this Home Assistant. Nothing to do with Google. It's a local based, open source home automation platform. I set mine up as a virtual machine on a Raspberry Pi.
> 
> The appeal would be that, depending on the plugs, it can control and poll them locally, eliminating a lot of the potential problems with using Alexa but allowing you to use the plugs you have already and not having to set up NodeMCUs and relay switches etc. Sort of a middle ground.


OOOOOOOO, this might be crazy useful! I'll have to look into this more. How deep have you got in configuring this? From the brief look I had on it, it's exactly what you said about removing the Amazon cloud link and just acting as the central hub for all control. My only concern with this is the ideal hardware to run it. Don't get me wrong, Raspberry Pi's are great tools, but being an SBC they have limitations. Thankfully they are cranking out new hardware almost annually, at the latest every 2 years. One thing I'd need to look into is an exportable config file. I hop hardware for Raspberry Pi's often, as soon as the latest hardware in the standard form factor is out I generally move in order to take advantage of the additional RAM and CPU components. I'd hate to have to rebuild and reconfig for every hop. If I can export a config file then this is extremely doable. Worst case, I'll just build a small gaming spec PC and focus on CPU and RAM instead of graphics and use that as a replacement... Or I could tie it into my personal VM stack, but this might be a little excessive.


----------



## Shrimply (Sep 20, 2020)

I don't think you'll have any concerns about transferring the set-up to a new device, there certainly appears to be plenty of guides available and backing up and restoring configuration files is all easily available. Installation was really quite simple following their instructions. It instantly recognised the Kasa Smart plugs on my network and allowed me local control without connecting to my TP-Link account.

The only issue being a warning that the program will soon require python 3.8 and I somehow managed to get myself into a bit of a mess getting python 3.8 onto the Pi as an altinstall and getting everything working again. 

I'm far far far from an expert, but I think an always on computer is probably the optimum solution. However, there is no harm on setting it up on Raspberry Pi and seeing how you get on. I'm far from taxing the software with only have a couple of smart devices currently in use, but my 4GB Raspberry Pi 4 seems to be running it alongside pi.hole nicely. Other than that all it does is some networking monitoring and NAS storage.

I think what makes this potentially super useful, and which I hadn't really considered is that it just doesn't know the current state of a device but also tracks the state, regardless of how the state is changed. I haven't delved too far into configuring this but it seems pretty much infinitely flexible. So you should be able to be able to turn off a device that has ran for too long, regardless of how it was started. Or possibly instantly turn off a device if it switches on and has already been ran for a given period of time in a day.


----------



## Tihsho (Sep 21, 2009)

Shrimply said:


> The only issue being a warning that the program will soon require python 3.8 and I somehow managed to get myself into a bit of a mess getting python 3.8 onto the Pi as an altinstall and getting everything working again.


Did you upgrade Python3 without going through the standard apt-get process? Generally, Python3 is constantly provided updates through the package manager as it's built into the Raspbian OS. If you upgraded this package specifically, make sure that it's still part of the apt-get process so that it's always updated when you run

# apt-get update

Otherwise if it's been pulled you will manually have to update the package which is just a hassle.


----------



## Shrimply (Sep 20, 2020)

Tihsho said:


> Did you upgrade Python3 without going through the standard apt-get process?


My understanding is that you won't get 3.8 via that apt-get process on Raspbian, because the kernel version won't be updated from 3.7 for some considerable time (certainly not by the 7th of December deadline of Home Assistant).

So you instead need to compile from source and use altinstall before changing the new install to the default python3 install. I think the my first attempt at this went slightly wrong and as a result I got confused and it took me a while to sort out. But it is all up and running perfectly fine now. I was probably just being a bit dim.


----------

