Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
devId = "1196962895"# output device id
tI = (float(indigo.devices[593268732].states["Temperature"]) )
tO = (float(indigo.devices[1336842918].states["Temperature"]))
hI = (float(indigo.devices[593268732].states["Humidity"]) )
hO = (float(indigo.devices[1336842918].states["Humidity"]))
p = (float(indigo.devices[1278464850].states["Pressure"]))
co2 = float(indigo.devices[1344322418].states["CO2"])
il = float(indigo.devices[864053974].states["illuminance"])
pr = float(indigo.devices[1062219179].states["Pressure"])
dir = (indigo.devices[375541516].states["directionText"])
speed = (indigo.devices[375541516].states["avgSpeed"])
AirQ = int(indigo.devices[593268732].states["AirQuality"])
pm25 = int(indigo.devices[91799756].states["pm25_standard"])
termLen = 800 # size of thermometer
tRange = [-15,45]
hRange = [20,100]
pRange = [980,1030]
co2Range = [380,600]
## set these params########
#positions
aClockCenter = [425, 425]
aClockRadius = [400, 400]
aClockWidth = 64 # w of hh, mm ss pointers and 2*pixels of ring on radius
dClockPos = [20, int(aClockCenter[1]+ aClockRadius[1]+ aClockWidth/2)+20 ]
dClockW = 130
zoom = 0.7
xTot = 1680 # x pixels
yTot = 1050# y pixel
xwindows = "on"
xwindowSize = str(int(xTot*zoom))+","+str(int(yTot*zoom))
y1F = 70 # y start of boxes
yfw = 300 # wdith of boxes
tOS = "{:.1f}".format(tO)
tOScale = int(-(tO-tRange[0])*termLen/(tRange[1]-tRange[0]))
tIS = "{:.1f}".format(tI)
tIScale = int(-(tI-tRange[0])*termLen/(tRange[1]-tRange[0]))
hIS = "{:.0f}".format(hI)
hIScale = int(-(hI-hRange[0])*termLen/(hRange[1]-hRange[0]))
hOS = "{:.0f}".format(hO)
hOScale = int(-(hO-hRange[0])*termLen/(hRange[1]-hRange[0]))
pS = "{:.1f}".format(p)
pScale = int(-(p-pRange[0])*termLen/(pRange[1]-pRange[0]))
co2S = "{:.1f}".format(co2)
co2Scale = int(-(co2-co2Range[0])*termLen/(co2Range[1]-co2Range[0]))
ilS = "{:.1f}".format(il)
prS = "{:.1f}".format(pr)
dirS = dir
speedS = "{:.1f}".format(speed)
AirQS = "{:d}".format(AirQ)
pm25S = "{:d}".format(pm25)
# same for all termometers:
yt1 = 70 # top
tL = 20 # length of tick line
tW = 3 # width of tick line
tF = 30 # font size Thermometers
## set these params######## END
# different x positions
xt1 = int(aClockCenter[0] + aClockRadius[0] + aClockWidth* 0.9)
xt2 = xt1+55
xt3 = xt2+120
xt4 = xt3+90
# for the 2 frames on the right:
frW = 5 # width of frame line
xF1 = xt4 + tL +10
fs1 = int(120./350. * yfw) # font size big
fs2 = int(fs1*0.8) # font size med
fs3 = int(fs1*0.7) # font size small
y2F = y1F + yfw + 100 # ystart of box 2
x1s = 20 # start of bix text
x2s = int(100/300. * yfw)
ys1 = 30 # start of big text
ys2 = yfw - fs2 - 50
#on, off,on time in seconds
onT1 = [0, 2, 6]
onT2 = [2, 2, 4]
onT3 = [4, 2, 2]
onT4 = [6, 2, 0]
# colors
# frames
colFTop = [255, 0, 0]
colFBot = [0, 255, 0]
# the thermometers
texC ="[ºC]" ;textCL = int(-tL/2)
texH ="%H" ;textHL = int(-tL/2)
texP ="[mBar]" ;textPL = int(-tL/2-2*tF)
texCO2 ="CO2" ;textCO2L = int(-tL/2-1.5*tF)
colBlack = [0,0,0]
colWhite = [255,255,255]
colt1T1 = [255, 255, 0] # yellow
colt1B1 = [0, 255, 0] # green
colt1B2 = [255, 0, 0] # red
colt1T2 = [50, 50, 255] # blue
colt2T1 = [255, 255, 0] # yellow
colt2B1 = [0, 255, 0] # green
colt2B2 = [255, 0, 0] # red
colt2T2 = [00, 00, 190] # blue
colt3T1 = [30, 200,200]
colt3B1 = [0, 0, 200]
colt4T1 = [30, 200,200]
colt4B1 = [50, 50, 255]
font = "Arial.ttf"
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
if not plug.isEnabled(): return
plug.executeAction("Display" , props ={
"outputDev":devId
,"device":"OUTPUT-Display"
,"restoreAfterBoot":"False"
,"xwindows":xwindows
,"xwindowSize":xwindowSize
,"intensity":""
,"repeat":"9999999"
,"resetInitial":""
,"scrollxy":""
,"zoom":str(zoom)
,"showDateTime":"0"
,"startAtDateTime":"0"
,"scrollPages":""
,"scrollDelay":""
,"scrollDelayBetweenPages":""
,"command":json.dumps(
[{"type":"rectangle", "position":[xF1, y1F, xTot-10, y1F+yfw+frW], "fill": colFTop, "display":"wait", "reset":[50, 50, 50]}
,{"type":"rectangle", "position":[xF1+frW, y1F+frW, xTot-10-frW, y1F+yfw], "fill":colBlack, "display":"wait"}
,{"type":"rectangle", "position":[xF1, y2F, xTot-10, y2F+yfw+frW], "fill": colFBot, "display":"wait"}
,{"type":"rectangle", "position":[xF1+frW, y2F+frW, xTot-10-frW, y2F+yfw], "fill":colBlack, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y1F+ys1], "width":fs1, "fill":colFTop, "font":font, "text":tOS+"[ºC]", "offONTime": onT1, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y1F+ys2], "width":fs2, "fill":colFTop, "font":font, "text":"outside", "offONTime": onT1, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y2F+ys1], "width":fs1, "fill":colFBot, "font":font, "text":tIS+"[ºC]", "offONTime": onT1, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y2F+ys2], "width":fs2, "fill":colFBot, "font":font, "text":"inside", "offONTime": onT1, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y1F+ys1], "width":fs1, "fill":colFTop, "font":font, "text":hOS+"[%H]", "offONTime": onT2, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y1F+ys2], "width":fs2, "fill":colFTop, "font":font, "text":"outside", "offONTime": onT2, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y2F+ys1], "width":fs1, "fill":colFBot, "font":font, "text":hIS+"[%H]", "offONTime": onT2, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y2F+ys2], "width":fs2, "fill":colFBot, "font":font, "text":"inside", "offONTime": onT2, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y1F+ys1], "width":fs1, "fill":colFTop, "font":font, "text":ilS, "offONTime": onT3, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y1F+ys2], "width":fs2, "fill":colFTop, "font":font, "text":"[Lux]", "offONTime": onT3, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y2F+ys1], "width":fs1, "fill":colFBot, "font":font, "text":prS, "offONTime": onT3, "display":"wait"}
,{"type":"text", "position":[xF1+x2s, y2F+ys2], "width":fs2, "fill":colFBot, "font":font, "text":"[mBar]", "offONTime": onT3, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y1F+ys1], "width":fs3, "fill":colFTop, "font":font, "text":dirS+" at", "offONTime": onT4, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y1F+ys2], "width":fs3, "fill":colFTop, "font":font, "text":speedS+"[Kmph]", "offONTime": onT4, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y2F+ys1], "width":fs3, "fill":colFBot, "font":font, "text":"AirQ:"+AirQS+"[%]", "offONTime": onT4, "display":"wait"}
,{"type":"text", "position":[xF1+x1s, y2F+ys2], "width":fs3, "fill":colFBot, "font":font, "text":"pm2.5: "+pm25S,"offONTime": onT4, "display":"wait"}
,{"type":"text", "display":"wait","width": tF, "fill": colt1T1, "font":font, "position":[int(xt1+ textCL),yt1-tF-10], "text": texC}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt1B1, "position":[xt1,yt1+termLen,tIScale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt1T1, "font":font, "position":["L",tW,[[0,""],[67,"-10"],[133,""],[200,"0"],[266,""],[333,"10"],[399,""],[467,"20"],[532,""],[599,"30"],[665,""],[732,"40"],[800,""]]]}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt1B2, "position":[xt1+ tL+2, yt1+termLen,tOScale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt1T1, "font":font, "position":["L",tW,[[0,""],[67,""],[133,""],[200,""],[266,""],[333,""],[399,""],[467,""],[532,""],[599,""],[665,""],[732,""],[800,""]]]}
,{"type":"text", "display":"wait","width": tF, "fill": colt2T2, "font":font, "position":[int(xt2+textHL),yt1-tF-10], "text": texH}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt2B1, "position":[xt2,yt1+termLen,hIScale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt2T2, "font":font, "position":["R",tW,[[0,""],[100,""],[200,""],[300,""],[400,""],[500,""],[600,""],[700,""],[800,""]]]}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt2B2, "position":[xt2+ tL+2, yt1+termLen,hOScale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt2T2, "font":font, "position":["R",tW,[[0,"20"],[100,"30"],[200,"40"],[300,"50"],[400,"60"],[500,"70"],[600,"80"],[700,"90"],[800,""]]]}
,{"type":"text", "display":"wait","width": tF, "fill": colt3T1, "font":font, "position":[int(xt3+textPL),yt1-tF-10], "text":texP}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt3B1, "position":[xt3,yt1+termLen, pScale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt3T1, "font":font, "position":["L", tW,[[0,"980"],[80,""],[160,"990"],[240,""],[320,"1000"],[400,""],[480,"1010"],[560,""],[640,"1020"],[720,""],[800,"1030"]]]}
,{"type":"text", "display":"wait","width": tF, "fill": colt4T1, "font":font, "position":[int(xt4+textCO2L),yt1-tF-10], "text":texCO2}
,{"type":"vBarwBox", "display":"wait","width": tL, "fill": colt4B1, "position":[xt4,yt1+termLen, co2Scale,-termLen]}
,{"type":"labelsForPreviousObject","display":"wait","width": tL, "fill": colt4T1, "font":font, "position":["L", tW,[[0,""],[80,"400"],[160,"420"],[240,"440"],[320,"460"],[400,"480"],[480,"500"],[560,"520"],[640,"540"],[720,"560"],[800,""]]]}
,{"type":"dateString", "position": dClockPos, "width":dClockW, "fill":colWhite, "font":font, "text":"%a, %b %d, %Y", "display":"wait"}
,{"type":"analogClock","position": aClockCenter, "width": aClockWidth, "font":font, "display":"immediate", "box":{"on": "circle", "width": "25", "fill": [100, 100, 100]}, "mm":{"fill": [0, 255, 0]}, "ticks":{"fill": [150, 150, 150]}, "ss":{"fill": [0, 0, 255]}, "hh":{"fill": [255, 0, 22]}, "radius": aClockRadius, "mode":"lineRound,,TicksNumbers"}])
})