Craig Swank avatar Craig Swank committed 07aa6e5

got temperature checker working on greenhouse example

Comments (0)

Files changed (1)

examples/greenhouse.py

 
     def event_received(self, event, message):
         sender = message.get('sender')
-        
+        print sender
         if sender in self._float_switches and self._float_switch_is_open(sender, message) and not self._too_cold:
             location = sender.replace(' float_switch', '')
             self.sockets.send('turn off {0} pump'.format(location))
             self._start_timer(location)
         elif sender == 'greenhouse temperature':
-            self._check_temperature(message):
+            self._check_temperature(message)
 
     def _check_temperature(self, message):
         t = self._get_greenhouse_temperature(message)
-        print 'is too cold?', t
-        if t < 15:
+        print 'is too cold?', t, message
+        if t < 15 and self._too_cold is False:
             self._too_cold = True
             self.sockets.send('turn on bed one pump')
             self.sockets.send('turn off bed two pump')
         else:
             self._too_cold = False
                         
-
-    def _greenhouse_temperature(self, message):
-        """
-        
-        """
-        return message.get('locations', {}).get('greenhouse', {}).get('temperature', {}).get('value')
+    def _get_greenhouse_temperature(self, message):
+        return message.get('locations', {}).get('greenhouse', {}).get('input', {}).get('temperature', {}).get('value')
 
     def _float_switch_is_open(self, sender, message):
         location = sender.replace(' float_switch', '')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.