Commit 8f8045a6 authored by Ľuboš Jenčík's avatar Ľuboš Jenčík
Browse files

edit notification

parent d8d74e8d
{"$":"592df333ee4c6ed611e42273120f437boPnq9dLq/xSlvLnAfEHJa0ZpYygZWtnpOmJbkyNLNQ5KgdrZIMPUnvYBwLZdhgQWuNRoHW6Sn8LRnWu84PutdpFm2cgbm7ICFA2hYrBv1iY="}
\ No newline at end of file
{"$":"d9c33d0f7f3bed72ca7adf5c7c5dd6d0GjSikXamlq8q6eD0k0w3Q4r/yWvWOHQoP8urCnfkX2YrF8MvimIWv/bEbefm42OEUCS7JIvsW/Mez4NZWjyGvxH5xjY1cC7sjBp/J+37UbqI6KwHd1+KEMUdfN4uXWaa1dLpWA=="}
\ No newline at end of file
This diff is collapsed.
from umqtt.robust import MQTTClient
from machine import Pin
from time import sleep
import separate
def setWell1(msg):
separate.well1 = msg
print(well1)
def setWell2(msg):
separate.well2 = msg
print(well2)
def getWell1():
return separate.well1
def getWell2():
return separate.well2
def do_connect(ssid, password):
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(ssid, password)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
do_connect('JencikWifi1', 'Matus2621996')
def callback(topic, message):
if(topic == b"irrigation/humidity1"):
humidity(topic, message)
elif(topic == b"irrigation/well/sensor/1"):
print("well1")
well1(topic, message)
elif(topic == b"irrigation/well/sensor/2"):
print("well2")
well2(topic, message)
elif(topic == b"irrigation/esp32/switch"):
print("pumpa vypnuta")
def humidity(topic, message):
value = int(message)
print(value)
global variable
if(value < 40):
variable = True
else:
variable = False
def well1(topic, message):
global topic1
setWell1(int(message))
topic1 = True
def well2(topic, message):
global topic2
setWell2(int(message))
topic2 = True
def switch(topic, message):
print("switch1 {}".format(message))
if(message == b"0"):
switch = True
led2 = Pin(4, Pin.OUT)
led1 = Pin(23, Pin.OUT)
variable = False
while True:
client = MQTTClient('esp32-lukas', 'broker.hivemq.com', 1883)
client.set_callback(callback)
client.connect()
client.subscribe('irrigation/humidity1')
print('Humidity .')
client.wait_msg()
client.wait_msg()
client.disconnect()
if(variable == True):
client = MQTTClient('esp32-lukas', 'broker.hivemq.com', 1883)
client.set_callback(callback)
client.connect()
client.subscribe('irrigation/well/sensor/1')
topic1 = False
while True:
print('Studne .')
client.wait_msg()
if(topic1 == True):
break;
client.disconnect()
client = MQTTClient('esp32-lukas', 'broker.hivemq.com', 1883)
client.set_callback(callback)
client.connect()
client.subscribe('irrigation/well/sensor/2')
topic2 = False
while True:
print('Studne .')
client.wait_msg()
if(topic2 == True):
break;
client.disconnect()
print(getWell1())
if(getWell1() >= getWell2()):
client = MQTTClient('esp32-lukas', 'broker.hivemq.com', 1883)
client.set_callback(callback)
client.connect()
num1 = "1"
client.publish('irrigation/esp32/pump', num1)
led1.on()
client.subscribe('irrigation/esp32/switch')
client.wait_msg()
client.wait_msg()
led1.off()
client.disconnect()
else:
client = MQTTClient('esp32-lukas', 'broker.hivemq.com', 1883)
client.set_callback(callback)
client.connect()
num1 = "2"
client.publish('irrigation/esp32/pump', num1)
led2.on()
client.subscribe('irrigation/esp32/switch')
client.wait_msg()
client.wait_msg()
led2.off()
client.disconnect()
\ No newline at end of file
from umqtt.robust import MQTTClient
from machine import ADC, Pin
from time import sleep
def do_connect(ssid, password):
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(ssid, password)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
do_connect('JencikWifi1', 'Matus2621996')
client = MQTTClient('esp32-lubos', 'broker.hivemq.com', 1883)
client.connect()
adc1 = ADC(Pin(34))
adc1.atten(ADC.ATTN_6DB)
adc2 = ADC(Pin(35))
adc2.atten(ADC.ATTN_6DB)
while True:
print('.')
num1 = str(adc1.read())
num2 = str(adc2.read())
client.publish('irrigation/well/sensor/1', num1)
sleep(2)
client.publish('irrigation/well/sensor/2', num2)
sleep(2)
\ No newline at end of file
2021.4.6
\ No newline at end of file
2021.4.5
\ No newline at end of file
......@@ -12,15 +12,15 @@
"user_id": "e1c1de7135b9419386f3b38ae8cdeb07",
"friendly_name": "Hackathon-2021"
},
"last_changed": "2021-04-29T16:39:33.421818+00:00",
"last_updated": "2021-04-29T16:39:35.005478+00:00",
"last_changed": "2021-04-29T23:10:36.232343+00:00",
"last_updated": "2021-04-29T23:10:53.783458+00:00",
"context": {
"id": "ef2b7140c8cf7fdeec2e50737f5d87e8",
"id": "e14ef186b16f9e73ec8c9654d0bbe59b",
"parent_id": null,
"user_id": null
}
},
"last_seen": "2021-04-29T19:13:53.728277+00:00"
"last_seen": "2021-04-29T23:12:03.991991+00:00"
},
{
"state": {
......
......@@ -2,12 +2,12 @@
"version": 1,
"key": "http",
"data": {
"ip_ban_enabled": true,
"server_port": 8123,
"login_attempts_threshold": -1,
"ssl_profile": "modern",
"cors_allowed_origins": [
"https://cast.home-assistant.io"
],
"login_attempts_threshold": -1,
"ip_ban_enabled": true,
"server_port": 8123
]
}
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment