SmartThings Community

Dog food countdown timer - My first attempt at a DTH


(Mike Harvey) #1

So I have wanted to create something with SmartThings for a while but don’t know how. I have started reading the docs files and have just started tinkering to see what I can do.

What I really wanted was a tile in the ST app that shows me how long is left before I need to feed the dog again. (usual problem, I don’t know if the gf has fed him already this morning etc.)

So I started with a virtual switch and have worked from there.

I now have a working DTH that counts down from a set number of hours and turns the switch on when the counter hits 0 this meant I can actually turn on a lamp at the same time with Smart Lighting App. (More on this later as I am planning to create an indicator light that sits in the dog food drawer!)

So it works and I am almost happy but there are a couple of improvements that I want to make and don’t know how. ANY SUGGESTIONS ARE MORE THAN WELCOME!

UPDATED!!!

So I really struggled trying to get a couple of things to work. I guess I have learnt now the difference between a DTH and a smartapp. I have now moved the automation bits (specifically the runIn() command) into the smartapp and kept the tile info etc in the DTH. I have also merged the DTH with one for a ZLL Dimmer bulb so it works exactly as I wanted and drives a bulb to act as an indicator.
The next step is to strip apart the bulb and create a battery powered led indicator using the board!!! (not sure how well this will go)

New DTH:

Smartapp:


Zigbee Switch DH not triggering zigbee.on/off methods() inside eventhandler?
(Mike Harvey) #3

I’d really love some feedback if anyone wants to comment.
I have zero background of programming and have amazed myself that I have managed to get this to work.
I put this DTH onto an Ikea Tradfri GU10 dimmer bulb and it works a treat.
I am pretty sure that I can strip the board out of that bulb next, power it from batteries and drive a small green LED so I have a device that indicates when the set amount of hours is up.
The Tradfri bulb was £7 so if I can get a small project box and battery holders for a few quid then I’m sure I can do this for little over a tenner!


(Mike Harvey) #4

OK, So I have been struggling along with this for quite a while now but finally have something reasonably useful.

So I managed to strip the zigbee chip out of the GU10 and with a little help from google found this:


This little chip is amazing, it is the same one Ikea use in all their tradfri devices, so can send actions or receive commands. It also supports bluetooth and Thread but I haven’t got the smarts to make use of that yet.

So just by ripping out that chip and soldering on 3 wires I can use this for the basis of my device. 2 wire supply power (should be 3.3v but will run at 1.85v) and one is the result of the dimming from Smartthings. So I soldered a standard green led to the output wire and hooked up the chip to two AA batteries and I could pair it with ST and control the LED. As the output voltage only goes up to the maximum of the batteries (2.4v) I didn’t bother adding any resistors for the led.
So just with this set up, I could turn the led on and off and also dim it as you would any zigbee bulb.

Unfortunately the batteries only lasted 4 days. I didn’t fancy adding pairs of batteries in parallel to try and increase the capacity so I gave up on the idea of batteries altogether.

So I now have a 3v power supply, and that it working great. But then I found a Duo-led with red and green in my garage from a project long ago and I started to think that would be cool. ie. if it is not green the it could be red!
So I looked up how to make a Not Logic Gate and it turned out all I need is a very cheap PNP transistor.
So by connecting that up with a 1kohm resistor to the led I found I can have ST turn the light on and the led goes green, when ST turns it off it goes red.
But because of the way these led work I can actually mix the red and green lights to create yellow and orange. I quickly gave up on trying to create 4 colours as you could then start to confuse yellow and green if you only quickly glanced at it.

BUT, I now have a small box with an led that can change from red to orange to green. very nicely.so i have tweeted the ZLL dimmer bulb dth so it sends levels to the form ikea chip where 0 is red, 65 is orange and 100 is green.


Im Still playing about with the dth and smartapp to automate it but they are working. so I can set an amount of time say, 8 hours, and tell alexa I have fed the dog and the led will turn red. when the hour counter gets to 1 hour left it goes to orange by setting the brightness to 65 and then when the time is up it goes green.

I’ll update the dth and smartapp in GitHub and post them up here when I have finished playing around if any wants to see it. But please feel free to comment on how I have done things wrong as This is all new to me and I am just amazed I have got something to work!!!


(Mike Harvey) #5

Here are the internals in case you want to see. it’s not very clear but the zigbee chip is on the left, the transistor is top right, there is a resistor joined to the transistor under the red shrink fit and obviously the led in the middle.

It’s that simple.