lawtancool / pyControl4

Python 3 asyncio package for interacting with Control4 systems
https://lawtancool.github.io/pyControl4
Apache License 2.0
38 stars 16 forks source link

OS3.4 issues #24

Closed nicgraner closed 9 months ago

nicgraner commented 9 months ago

Hi, it looks like with OS3.4 item variable values are broken.

Using this code here: `from pyControl4.account import C4Account from pyControl4.director import C4Director from pyControl4.room import C4Room from pyControl4.light import C4Light import Encoder import RPi.GPIO as GPIO from time import sleep import asyncio import json

#############Variables############### username = "########" password = "########" ip = "###########" #####################################

##########C4 Auth and light to control definition################ """Authenticate with Control4 account""" account = C4Account(username, password) asyncio.run(account.getAccountBearerToken())

"""Get and print controller name""" accountControllers = asyncio.run(account.getAccountControllers()) print(accountControllers["controllerCommonName"])

"""Get bearer token to communicate with controller locally""" director_bearer_token = asyncio.run(account.getDirectorBearerToken(accountControllers["controllerCommonName"]))["token"] print("im still alive") """Create new C4Director instance""" director = C4Director(ip, director_bearer_token)

tells the pi which light to change

light = C4Light(director, 2352) print("i've defined the light class")

def Light_state(): return asyncio.run(light.getState()) print(Light_state(),"the light_state class is working")`

the code is able to connect to the controller, identify the light, but when it prints the light state, it fails with:


  File "/home/nicgraner/test.py", line 38, in <module>
    print(Light_state(),"the light_state class is working")
  File "/home/nicgraner/test.py", line 37, in Light_state
    return asyncio.run(light.getState())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/nicgraner/.local/lib/python3.9/site-packages/pyControl4/light.py", line 18, in getState
    value = await self.director.getItemVariableValue(self.item_id, "LIGHT_STATE")
  File "/home/nicgraner/.local/lib/python3.9/site-packages/pyControl4/director.py", line 160, in getItemVariableValue
    data = await self.sendGetRequest(
  File "/home/nicgraner/.local/lib/python3.9/site-packages/pyControl4/director.py", line 56, in sendGetRequest
    await checkResponseForError(await resp.text())
  File "/home/nicgraner/.local/lib/python3.9/site-packages/pyControl4/error_handling.py", line 112, in checkResponseForError
    if dictionary["details"] in DIRECTOR_ERROR_DETAILS:
KeyError: 'details'```
nicgraner commented 9 months ago

Nevermind, somehow my roomID had changed on me, was all user error :)