-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunfile.py
More file actions
30 lines (22 loc) · 787 Bytes
/
runfile.py
File metadata and controls
30 lines (22 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import uasyncio as asyncio
from home_sensor.controllers import ESP32S2
from home_sensor.sensors import BME280Sensor
from home_sensor.clients import MQTT
from home_sensor.hosts import HomeAssistant
from home_sensor.api import run_controller
esp32s2 = ESP32S2()
esp32s2.set_wifi_parameters({"ssid": "MySSID-2io32p", "password": "Pa55w0rd"})
mqtt_client = MQTT()
home_assistant = HomeAssistant()
home_assistant.host_address = "192.168.1.200"
mqtt_parameters = {
"client_id": esp32s2.id,
"server": home_assistant.host_address,
"keepalive": 60,
}
mqtt_client.set_parameters(mqtt_parameters)
esp32s2.register_client(mqtt_client)
esp32s2.register_host(home_assistant)
bme280_sensor = BME280Sensor()
esp32s2.add_sensor(bme280_sensor)
asyncio.run(run_controller(esp32s2, 30))