fix HA sync issue, still no color lol
This commit is contained in:
+15
-11
@@ -1,9 +1,9 @@
|
|||||||
from logging import handlers
|
from os import getenv
|
||||||
from requests import get
|
from requests import get
|
||||||
from requests import post
|
from requests import post
|
||||||
from json import loads
|
from json import loads
|
||||||
|
from json import load
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from requests import Session, post
|
|
||||||
|
|
||||||
# https://github.com/slattery-mark/SteelSeries-CKL-App
|
# https://github.com/slattery-mark/SteelSeries-CKL-App
|
||||||
# author: slattery-mark
|
# author: slattery-mark
|
||||||
@@ -16,12 +16,11 @@ haHeaders = {
|
|||||||
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI0ZmQ4MzQxNTZjNjg0YThlYTFjY2NiYmNkNWEzYTI4OSIsImlhdCI6MTY2NjExMDcwMiwiZXhwIjoxOTgxNDcwNzAyfQ.5KVla7Y72yKFrWhF01EupQpSHX0Rbr0CQ-LMLW6v6VU",
|
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI0ZmQ4MzQxNTZjNjg0YThlYTFjY2NiYmNkNWEzYTI4OSIsImlhdCI6MTY2NjExMDcwMiwiZXhwIjoxOTgxNDcwNzAyfQ.5KVla7Y72yKFrWhF01EupQpSHX0Rbr0CQ-LMLW6v6VU",
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
}
|
}
|
||||||
gsAddress = "http://127.0.0.1:50786"
|
gsCorePropsPath = getenv('PROGRAMDATA') + "\SteelSeries\SteelSeries Engine 3\coreProps.json"
|
||||||
|
gsAddress = f'http://{load(open(gsCorePropsPath))["address"]}'
|
||||||
gsGame = "HA_LIGHT_SYNC"
|
gsGame = "HA_LIGHT_SYNC"
|
||||||
gsEvent = "SYNC"
|
gsEvent = "SYNC"
|
||||||
redRGB = 0
|
|
||||||
greenRGB = 0
|
|
||||||
blueRGB = 0
|
|
||||||
|
|
||||||
def checkLight():
|
def checkLight():
|
||||||
""" Check HA light color """
|
""" Check HA light color """
|
||||||
@@ -29,6 +28,10 @@ def checkLight():
|
|||||||
haData = loads(haResponse.text)
|
haData = loads(haResponse.text)
|
||||||
return haData['attributes']['rgb_color']
|
return haData['attributes']['rgb_color']
|
||||||
|
|
||||||
|
redRGB = checkLight()[0]
|
||||||
|
greenRGB = checkLight()[1]
|
||||||
|
blueRGB = checkLight()[2]
|
||||||
|
|
||||||
def updateLight():
|
def updateLight():
|
||||||
global redRGB
|
global redRGB
|
||||||
global greenRGB
|
global greenRGB
|
||||||
@@ -97,26 +100,27 @@ def sendGameEvent(kill_switch):
|
|||||||
"game": gsGame,
|
"game": gsGame,
|
||||||
"event": gsEvent,
|
"event": gsEvent,
|
||||||
"data" : {
|
"data" : {
|
||||||
|
"value" : 100,
|
||||||
"frame": {
|
"frame": {
|
||||||
"zone-all-color": {
|
"zone-all-color": {
|
||||||
"color": {"red": redRGB,"green": greenRGB,"blue": blueRGB}
|
"color": {"red": 0,"green": 0,"blue": 0}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with Session() as s:
|
|
||||||
while kill_switch == 0:
|
while kill_switch == 0:
|
||||||
|
|
||||||
""" DEBUG """
|
""" DEBUG """
|
||||||
print("[+] loopyloop")
|
print("[+] loopyloop")
|
||||||
""" DEBUG """
|
""" DEBUG """
|
||||||
print("[+] sendGameEvent(kill_switch)")
|
|
||||||
print("[+] update light RGB state")
|
print("[+] update light RGB state")
|
||||||
updateLight()
|
updateLight()
|
||||||
r = s.post(endpoint, json=payload)
|
payload['data']['frame']['zone-all-color']['color'] = {"red": redRGB,"green": greenRGB,"blue": blueRGB}
|
||||||
|
print("[+] sendGameEvent(kill_switch)")
|
||||||
|
r = post(endpoint, json=payload)
|
||||||
print(r.text)
|
print(r.text)
|
||||||
|
|
||||||
if kill_switch == 1: break
|
if kill_switch == 1: break
|
||||||
|
|
||||||
""" DEBUG """
|
""" DEBUG """
|
||||||
|
|||||||
Reference in New Issue
Block a user