2. create an action that is triggered when temperature changes:
- Code: Select all
##=======use this as a python script in an action group action :=====
import json
il = float(indigo.devices[393522233].states["illuminance"])
lightFactor = max( min(il/ 100., 1), 2./255. )
tO = (float(indigo.devices[1336842918].states["Temperature"]))
tRange = [-20,50] # -20C .. +50C
# tscale is 0..140
termLen = 140
tOScale = int( termLen*(tO -tRange[0]) /float(tRange[1] -tRange[0]) )
# the elements in thermometer are:[ [col=0, led1, R G,B], [col=0, led2, R,G,B], [col=0, led3, R,G,B]...]
thermometer = []
for ii in range(termLen+3):# 142 pixels, tscale is 0..140
thermometer.append([0,ii+1,0,0,0])
if tOScale > ii:
thermometer[ii][2] = int(2)
if tOScale == ii:
thermometer[ii][2] = int(255* lightFactor)
if ii%10 == 0:
thermometer[ii][2] = 0
thermometer[ii][3] = 0
thermometer[ii][4] = 2
if ii%20 == 0:
thermometer[ii][0] = 0
thermometer[ii][3] = 5
thermometer[ii][4] = 5
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
plug.executeAction("Neopixel" , props ={
"outputDev":"246403135"
,"device":"OUTPUT-neopixel"
,"restoreAfterBoot":"false"
,"intensity":100
,"repeat":1
,"resetInitial":"[0, 0, 0]"
,"command":json.dumps([ { "type": "points"
, "position": thermometer
}])
})
3. connect the neopixel strip through a level shifter to pin# 18=digital PWN out, +5V GND -- and on the neopixel side GND,+5V, Di
The neo pixel strip is mounted on a plane long piece of wood
Karl