little bits
This commit is contained in:
		
							parent
							
								
									eda62774ec
								
							
						
					
					
						commit
						462afbe4da
					
				
							
								
								
									
										5
									
								
								mqtt.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								mqtt.py
									
									
									
									
									
								
							@ -1,5 +1,4 @@
 | 
				
			|||||||
import random
 | 
					import random
 | 
				
			||||||
import time
 | 
					 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from paho.mqtt import client as mqtt_client
 | 
					from paho.mqtt import client as mqtt_client
 | 
				
			||||||
@ -40,10 +39,10 @@ def connect_mqtt() -> mqtt_client:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def publish(client):
 | 
					def publish(client):
 | 
				
			||||||
    result = client.publish("ledLight/state", "on")
 | 
					    result = client.publish("ledLight/state", "ON")
 | 
				
			||||||
    status = result[0]
 | 
					    status = result[0]
 | 
				
			||||||
    if status == 0:
 | 
					    if status == 0:
 | 
				
			||||||
        print(f"Send `on` to topic `{topic}`")
 | 
					        print(f"Send `ON` to topic `{topic}`")
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print(f"Failed to send message to topic {topic}")
 | 
					        print(f"Failed to send message to topic {topic}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user