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

Error on OS 3.4 -- asyncio.run(account.getAccountBearerToken()) #23

Closed umoraes closed 8 months ago

umoraes commented 10 months ago

hi... I'm running a C4 EA1 OS 3.4 and my first test.py to test the controller to list all devices, I get this error:

Exception has occurred: BadCredentials {"C4ErrorResponse":{"code":401,"details":"Permission denied Bad credentials","message":"Permission denied","subCode":0}} File "C:\tmp\C4\2\a.py", line 14, in asyncio.run(account.getAccountBearerToken()) pyControl4.error_handling.BadCredentials: {"C4ErrorResponse":{"code":401,"details":"Permission denied Bad credentials","message":"Permission denied","subCode":0}}

I'm using root users on python... password is correct (I changed it to t0talc0ntr0l4! since its lower than 40 letters.

asyncio.run(account.getAccountBearerToken()) is where I get error.

Is there something that needs to be configured in addition to username, password and ip? Is there a C4 drive needed to use this code?

I'm using the basic code... here it's:

from pyControl4.account import C4Account from pyControl4.director import C4Director from pyControl4.light import C4Light import asyncio import json

username = "root" password = "t0talc0ntr0l4!" ip = "192.168.1.23" # Substitua pelo endereço IP do seu Control4 Director

"""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"]

"""Create new C4Director instance""" director = C4Director(ip, director_bearer_token)

"""Print all devices on the controller""" print(asyncio.run(director.getAllItemInfo()))

"""Create new C4Light instance""" light = C4Light(director, 253)

"""Ramp light level to 10% over 10000ms""" asyncio.run(light.rampToLevel(10, 10000))

"""Print state of light""" print(asyncio.run(light.getState()))

nicgraner commented 9 months ago

your account credentials are needed, not the credentials for the controller, so whatever you use to log in to the control4 app is what you should have instead of root and total control.

umoraes commented 9 months ago

thanks in advance!!! I will try at night

On Mon, Nov 13, 2023 at 12:59 PM Maconic @.***> wrote:

your account credentials are needed, not the credentials for the controller, so whatever you use to log in to the control4 app is what you should have instead of root and total control.

— Reply to this email directly, view it on GitHub https://github.com/lawtancool/pyControl4/issues/23#issuecomment-1808449606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWYUIQ4QALU35ANCPMNA423YEI7XDAVCNFSM6AAAAAA6KTTO3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYGQ2DSNRQGY . You are receiving this because you authored the thread.Message ID: @.***>