initial commit of mqtt client
This commit is contained in:
		
							parent
							
								
									337fb76e30
								
							
						
					
					
						commit
						cc3a21b0d1
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		
							
								
								
									
										5
									
								
								mqtt.py
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								mqtt.py
									
										
									
									
									
								
							| 
						 | 
					@ -7,9 +7,10 @@ def on_connect(client, userdata, flags, reason_code, properties):
 | 
				
			||||||
    print(f"Connected with result code {reason_code}")
 | 
					    print(f"Connected with result code {reason_code}")
 | 
				
			||||||
    # Subscribing in on_connect() means that if we lose the connection and
 | 
					    # Subscribing in on_connect() means that if we lose the connection and
 | 
				
			||||||
    # reconnect then subscriptions will be renewed.
 | 
					    # reconnect then subscriptions will be renewed.
 | 
				
			||||||
    client.subscribe("$SYS/#")
 | 
					    #client.subscribe("$SYS/#")
 | 
				
			||||||
    client.subscribe('test/hallo')
 | 
					    client.subscribe('test/topic')
 | 
				
			||||||
    client.subscribe('homeassistant/status')
 | 
					    client.subscribe('homeassistant/status')
 | 
				
			||||||
 | 
					    publish.single('test/topic', 'Hello, MQTT!', hostname='192.168.188.30', auth={'username': 'mqtt', 'password': 'mqtt'})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# The callback for when a PUBLISH message is received from the server.
 | 
					# The callback for when a PUBLISH message is received from the server.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue