Created
June 28, 2022 21:54
-
-
Save ralight/e5d5652e150fc46a466af98f12190b53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paho.mqtt.subscribe as subscribe | |
import json | |
import os | |
def on_message(client, userdata, msg): | |
#print(msg.topic+" "+str(msg.payload)) | |
payload = json.loads(msg.payload) | |
if "action" in payload and "rgb" in payload and "mac" in payload: | |
if payload['mac'] == "23:02:04:00:01:c6": | |
r,g,b = payload['rgb'] | |
hex_col = f'{r:02x}' + f'{g:02x}' + f'{b:02x}' | |
cmd = "ratbagctl cheering-viscacha led 0 set color " + hex_col | |
print(cmd) | |
os.system(cmd) | |
subscribe.callback(on_message, hostname="mqtt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment