wordclock-dimmer: Make logging less verbose
The time is already stored in the journal, so it does not need to be logged. Only logging changed values makes the log less polluted once a fixed value has been reached ((3, 3, 3) or (3, 0, 0)):
This commit is contained in:
parent
8f1d0a149c
commit
939df6ae2a
|
@ -61,15 +61,6 @@ def get_color_for_time(time: datetime.time, base=(60, 60, 60)) -> (int, int, int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def update(client: mqtt.Client):
|
|
||||||
time = datetime.datetime.now().time()
|
|
||||||
color = get_color_for_time(time)
|
|
||||||
print(f"{time}: setting color to {color}")
|
|
||||||
sys.stdout.flush()
|
|
||||||
set_color(client, *color)
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
client = mqtt.Client("wordclock.py")
|
client = mqtt.Client("wordclock.py")
|
||||||
|
|
||||||
user = os.environ["WORDCLOCK_MQTT_USER"]
|
user = os.environ["WORDCLOCK_MQTT_USER"]
|
||||||
|
@ -83,6 +74,15 @@ host = os.environ["WORDCLOCK_MQTT_HOST"]
|
||||||
client.username_pw_set(user, password)
|
client.username_pw_set(user, password)
|
||||||
client.connect(host, 1883, 60)
|
client.connect(host, 1883, 60)
|
||||||
|
|
||||||
|
color = (0, 0, 0)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
update(client)
|
time = datetime.datetime.now().time()
|
||||||
|
new_color = get_color_for_time(time)
|
||||||
|
if new_color != color:
|
||||||
|
color = new_color
|
||||||
|
print(f"setting color to {color}")
|
||||||
|
sys.stdout.flush()
|
||||||
|
set_color(client, *color)
|
||||||
|
|
||||||
sleep(300)
|
sleep(300)
|
||||||
|
|
Loading…
Reference in a new issue