# HG changeset patch # User drewp@bigasterisk.com # Date 1446918600 28800 # Node ID 40000fafad944ff208ad04a4412594ab7f01f95a # Parent 9a3b8f1aaf7883cba88e2c908d83093df2382df2 piNode onboard temp Ignore-this: 2e603499925ff5a114273057a07fb36a diff -r 9a3b8f1aaf78 -r 40000fafad94 service/piNode/config.n3 --- a/service/piNode/config.n3 Sun Oct 04 04:19:26 2015 -0700 +++ b/service/piNode/config.n3 Sat Nov 07 09:50:00 2015 -0800 @@ -9,6 +9,7 @@ ha:node2 a :PiBoard; :hostname "sticker"; + :onboardDevice ha:bedroomPiTemp . :hasPin board2pin:GPIO2, board2pin:GPIO3, @@ -17,6 +18,8 @@ board2pin:GPIO27 . +ha:bedroomPiTemp a :OnboardTemperature . + board2pin:GPIO2 :gpioNumber 2 . board2pin:GPIO3 :gpioNumber 3 . board2pin:GPIO4 :gpioNumber 4 . diff -r 9a3b8f1aaf78 -r 40000fafad94 service/piNode/devices.py --- a/service/piNode/devices.py Sun Oct 04 04:19:26 2015 -0700 +++ b/service/piNode/devices.py Sat Nov 07 09:50:00 2015 -0800 @@ -176,6 +176,31 @@ 'pred': ROOM['color'], }] +@register +class OnboardTemperature(DeviceType): + deviceType = ROOM['OnboardTemperature'] + @classmethod + def findInstances(cls, graph, board, pi): + for row in graph.query('''SELECT DISTINCT ?dev WHERE { + ?board :onboardDevice ?uri . + ?uri a :OnboardTemperature . + }'''): + yield cls(graph, row.uri, pi, pinNumber=None) + + def readFromPoll(self): + milliC = open('/sys/class/thermal/thermal_zone0/temp').read().strip() + c = float(milliC) / 1000. + f = c * 1.8 + 32 + return [ + (self.uri, ROOM['temperatureF'], Literal(f, datatype=XSD['decimal'])), + ] + + def watchPrefixes(self): + # these uris will become dynamic! see note on watchPrefixes + # about eliminating it. + return [(self.uri, ROOM['temperatureF']), + ] + def makeDevices(graph, board, pi): out = [] for dt in sorted(_knownTypes, key=lambda cls: cls.__name__):