Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify public API #101

Open
henryruhs opened this issue Feb 6, 2022 · 0 comments
Open

Simplify public API #101

henryruhs opened this issue Feb 6, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@henryruhs
Copy link
Contributor

henryruhs commented Feb 6, 2022

In my personal opinion, the public API should be much more simpler. Developers who jump on board should not have to deal with PilotBuilder and asyncio as this are internals and should not be part of implementations. Once you switch one of these, the upgrade paths are going to be a nightmare.

I have helpers like that in my code - it is too complex just to get the name of a light:

def get_light_name(light : Any) -> str:
	return light.loop.run_until_complete(light.get_bulbtype()).name

Why not just:

light.name

# Or just a collection that contains all the things

light.info()['name']

This is an suggestion of a potential future API - we can still have await but also handy _sync methods:

await light.turn_on()
# Set bulb brightness
await light.turn_on(brightness = 255)
# Provide sync calls aswell using run_until_complete internal
light.turn_on_sync(brightness = 255)

# Set bulb brightness (with async timeout)
timeout = 10
await light.turn_on(brightness = 255), timeout)

# Set bulb to warm white
await light.turn_on(warm_white = 255)

# Set RGB values
# red to 0 = 0%, green to 128 = 50%, blue to 255 = 100%
await light.turn_on(rgb = (0, 128, 255))

As you can see this looks easier and both dependencies are hidden. I don't want to offend someone, this is just honest feedback to make everyone's life easier. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants