light: change mqtt broker
Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/light.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/light.py
									
									
									
									
									
								
							@@ -4,17 +4,15 @@ Created on Dec 24, 2016
 | 
				
			|||||||
@author: tkl
 | 
					@author: tkl
 | 
				
			||||||
'''
 | 
					'''
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
from time import time
 | 
					import time
 | 
				
			||||||
import paho.mqtt.client as mqtt
 | 
					 | 
				
			||||||
from light_sensor.light_sensor import light_sensor
 | 
					from light_sensor.light_sensor import light_sensor
 | 
				
			||||||
 | 
					import mqtt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    client = mqtt.Client()
 | 
					    conn = mqtt.Mqtt(hostname='proxy')
 | 
				
			||||||
    client.connect("192.168.178.37", 1883, 60)
 | 
					 | 
				
			||||||
    client.loop_start()
 | 
					 | 
				
			||||||
    light = light_sensor(1, 0x23)
 | 
					    light = light_sensor(1, 0x23)
 | 
				
			||||||
    client.publish("chickenhouse/sensors/light", str(int(time())) + " " + \
 | 
					    conn.transmit("outdoor/chickenhouse/sensors/light", str(int(time.time())) + " " + \
 | 
				
			||||||
                   str(light.read()) + " lx")
 | 
					                  str(light.read()) + " lx")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    sys.exit(main())
 | 
					    sys.exit(main())
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user