-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
21 lines (19 loc) · 791 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import time
import solarman_mqtt.environment as environment
from solarman_mqtt.solarman import SolarmanAPI, State
from solarman_mqtt.homebridge_mqtt import HomebridgeMQTT
if __name__ == "__main__":
print("Booting")
print(f"Will poll every {environment.POLL_INTERVAL} seconds")
solarman_api = SolarmanAPI(
environment.SOLARMAN_USERNAME, environment.SOLARMAN_PASSWORD
)
homebridge_mqtt = HomebridgeMQTT(environment.MQTT_BROKER_HOST, port=environment.MQTT_BROKER_PORT)
while True:
state: State = solarman_api.get_state(
device_id=environment.SOLARMAN_DEVICE_ID,
site_id=environment.SOLARMAN_SITE_ID,
)
print(f"{state=}")
homebridge_mqtt.publish_state(state)
time.sleep(environment.POLL_INTERVAL)