Merge branch 'main' of https://git.jerick.xyz/jerick/homeassistantPi
This commit is contained in:
@@ -16,6 +16,13 @@ password = 'falrenforbreakfast'
|
|||||||
|
|
||||||
client_id = f'python-mqtt-office-{random.randint(0, 1000)}'
|
client_id = f'python-mqtt-office-{random.randint(0, 1000)}'
|
||||||
|
|
||||||
|
#We first check if a libgpiod process is running. If yes, we kill it!
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei':
|
||||||
|
proc.kill()
|
||||||
|
|
||||||
|
#D20 is the pin number, DHT11 is the sensor type
|
||||||
|
sensor = adafruit_dht.DHT11(board.D20)
|
||||||
|
|
||||||
#Function Definitions
|
#Function Definitions
|
||||||
def connect_mqtt():
|
def connect_mqtt():
|
||||||
@@ -80,13 +87,6 @@ def publish(client, temp, humidity):
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
#We first check if a libgpiod process is running. If yes, we kill it!
|
|
||||||
for proc in psutil.process_iter():
|
|
||||||
if proc.name() == 'libgpiod_pulsein' or proc.name() == 'libgpiod_pulsei':
|
|
||||||
proc.kill()
|
|
||||||
|
|
||||||
#D20 is the pin number, DHT11 is the sensor type
|
|
||||||
sensor = adafruit_dht.DHT11(board.D20)
|
|
||||||
#Run functions
|
#Run functions
|
||||||
client = connect_mqtt() # Connect to Broker
|
client = connect_mqtt() # Connect to Broker
|
||||||
client.loop_start() #Start loop
|
client.loop_start() #Start loop
|
||||||
|
|||||||
Reference in New Issue
Block a user