kinda work

This commit is contained in:
quoije
2022-10-20 23:25:56 -04:00
parent 0d993489d4
commit 80a2d045f6
+18 -14
View File
@@ -8,6 +8,11 @@ from time import sleep
# https://github.com/slattery-mark/SteelSeries-CKL-App # https://github.com/slattery-mark/SteelSeries-CKL-App
# author: slattery-mark # author: slattery-mark
# modified by quoije # modified by quoije
# work with steelseries apex 3 keyboard, 10 zones
#
# change haAddress to your hass server, change haLight to your light entity
# change gsGame, gsEvent to desired steelseries engine name
# change sleepTime to desired time of sleep between post request to ss engine
haAddress = "192.168.0.42" haAddress = "192.168.0.42"
haLight = "light.sb50_l4" haLight = "light.sb50_l4"
@@ -20,7 +25,7 @@ gsCorePropsPath = getenv('PROGRAMDATA') + "\SteelSeries\SteelSeries Engine 3\cor
gsAddress = f'http://{load(open(gsCorePropsPath))["address"]}' gsAddress = f'http://{load(open(gsCorePropsPath))["address"]}'
gsGame = "HA_LIGHT_SYNC" gsGame = "HA_LIGHT_SYNC"
gsEvent = "SYNC" gsEvent = "SYNC"
sleepTime = 1.00
def checkLight(): def checkLight():
""" Check HA light color """ """ Check HA light color """
@@ -85,9 +90,9 @@ def bindGameEvent():
"event": gsEvent, "event": gsEvent,
"handlers": [{ "handlers": [{
"mode": "context-color", "mode": "context-color",
"device-type": "keyboard", "device-type": "rgb-zoned-device",
"zone": "all", "zone": "one",
"context-frame-key": "zone-all-color" "context-frame-key": "zone-color"
}] }]
} }
r = post(endpoint, json=payload) r = post(endpoint, json=payload)
@@ -100,10 +105,9 @@ def sendGameEvent(kill_switch):
"game": gsGame, "game": gsGame,
"event": gsEvent, "event": gsEvent,
"data" : { "data" : {
"value" : 100,
"frame": { "frame": {
"zone-all-color": { "zone-color": {
"color": {"red": redRGB,"green": greenRGB,"blue": blueRGB} "red": 0,"green": 0,"blue": 0
} }
} }
} }
@@ -117,7 +121,7 @@ def sendGameEvent(kill_switch):
print("[+] update light RGB state") print("[+] update light RGB state")
updateLight() updateLight()
payload['data']['frame']['zone-all-color']['color'] = {"red": redRGB,"green": greenRGB,"blue": blueRGB} payload['data']['frame']['zone-color'] = {"red": redRGB,"green": greenRGB,"blue": blueRGB}
print("[+] sendGameEvent(kill_switch)") print("[+] sendGameEvent(kill_switch)")
r = post(endpoint, json=payload) r = post(endpoint, json=payload)
print(r.text) print(r.text)
@@ -127,15 +131,15 @@ def sendGameEvent(kill_switch):
print("[+] HA RGB: " + str(checkLight()[0]) + " " + str(checkLight()[1]) + " " + str(checkLight()[2])) print("[+] HA RGB: " + str(checkLight()[0]) + " " + str(checkLight()[1]) + " " + str(checkLight()[2]))
""" DEBUG """ """ DEBUG """
sleep(1.01) sleep(sleepTime)
print("[+] removing game event for debug") print("[+] removing game event")
removeGameEvent() removeGameEvent()
print("[+] removing game for debug") print("[+] removing game")
removeGame() removeGame()
print("[+] register game for debug") print("[+] register game")
registerGame() registerGame()
print("[+] bind game for debug") print("[+] bind game")
bindGameEvent() bindGameEvent()
print("[+] send game for debug") print("[+] send game")
sendGameEvent(0) sendGameEvent(0)