Guest User

Untitled

a guest
May 4th, 2016
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # create Devices on the network
  2.         self.Fosset = self.Network.add_device(21,
  3.                                               "int Command;" +
  4.                                               "byte Flow;" +
  5.                                               "int Temp;",
  6.                                               "Fosset")
  7.         self.UnderTub = self.Network.add_device(22,
  8.                                                 "int Command;" +
  9.                                                 "int PipeTemp;" +
  10.                                                 "int HotTubTemp;" +
  11.                                                 "int OutsideTemp;" +
  12.                                                 "bool ValveIsOpen;" +
  13.                                                 "int OverflowTemp",
  14.                                                 "UnderTub")
  15.         self.Fosset.add_translation('Command',
  16.                                     ('Unfreeze', 2101),
  17.                                     ('Regulate', 2102),
  18.                                     ('Status', 99))
  19.         self.UnderTub.add_translation('Command',
  20.                                       ('Status', 99),
  21.                                       ('OpenValve', 2201),
  22.                                       ('CloseValve', 2202))
  23.  
  24.  
  25. # and later i use for example:
  26.  def prevent_freezing(self):
  27.         print "Here I come to save the day!... by preventing pipe freezing"
  28.         d = self.UnderTub.send_and_receive('Status')  # get status from UnderTub
  29.         if not d:   # if we don't get anything d will be None
  30.             print "prevent_freezing <- UnderTub is not responding!!!"
  31.         else:
  32.             if d['OutsideTemp'] < 0:  # if there are freezing conditions
  33.                 if d['PipeTemp'] < 20:  # 20 means 2.0 °C
  34.                     print "It's my time to shine! There'll be no pipe freezing today mister!"
  35.                     if not d['ValveIsOpen']:
  36.                         self.UnderTub.send('OpenValve')  # make sure valve is open
  37.                     self.Fosset.send('Unfreeze')
  38.                     # sending unfreeze means it will send hot water through for 60 seconds
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×