def setUp(self): serspec = ['read', 'write', 'open', 'close'] serport = Mock(name="serport", spec=serspec) serport.open.return_value = True serport.close.return_value = True serport.read.return_value = [ 129, 75, 0, 1, 0, 0, 0, 64, 0, 0, 64, 0, 19, 3, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 20, 0, 12, 22, 28, 1, 1, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 170, 0, 1, 3, 22, 22, 22, 8, 0, 21, 9, 30, 16, 16, 30, 22, 23, 0, 17, 9, 0, 21, 22, 0, 16, 24, 0, 16, 24, 0, 16, 127, 117 ] self.con = serport self.thermostat1 = heatmiser.HeatmiserThermostat(1, 'prt', self.con)
def setUp(self): """Creates serial con and thermostat""" self.con = connection.hmserial('192.168.1.57', '100') self.con.open() self.thermostat1 = heatmiser.HeatmiserThermostat(1, 'prt', self.con)
import logging """ This examples shows a simple setup of a single UH1 Heatmiser Wiring Centre, and the addition of 4 'prt' thermostats. The script below then iterates through, setting the target temp on them all to 20. """ IP_ADDRESS = '192.168.1.57' PORT = '102' logging.basicConfig(level=logging.INFO) # Create a HeatmiserUH! connection HeatmiserUH1 = connection.HeatmiserUH1(IP_ADDRESS, PORT) # Add my thermostats thermo1 = heatmiser.HeatmiserThermostat(1, 'prt', HeatmiserUH1) thermo2 = heatmiser.HeatmiserThermostat(2, 'prt', HeatmiserUH1) thermo3 = heatmiser.HeatmiserThermostat(3, 'prt', HeatmiserUH1) thermo4 = heatmiser.HeatmiserThermostat(4, 'prt', HeatmiserUH1) # Show them registeresd against the UH1 for tstat in HeatmiserUH1.thermostats: logging.info(HeatmiserUH1.thermostats[tstat].set_target_temp(19)) # You can also just hit the themos directly: thermo1.get_target_temp() thermo1.get_floor_temp()