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

New services adaptive_lighting.turn_on turn_off toggle with optional switch/lights args #559

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

th3w1zard1
Copy link
Collaborator

@th3w1zard1 th3w1zard1 commented Apr 8, 2023

Now that we have lookups for our optional lights or switches arguments, I figure some new service calls to support that would be welcome.

Tests are written and everything else in const.py

Ran into this problem while trying to modify some of my HASS automations. Mainly the wake-up script as it currently just disables adaptive lighting and does its own transitioning.

With this PR I simply need to call one service:

service: adaptive_lighting.turn_off
data:
  lights:
    - light.bedside_lamp
    - light.bedroom_ceilingfan_lights
  switch_type: "sleep"

'function too complex'
@th3w1zard1 th3w1zard1 changed the title Add new service calls New service calls turn_on turn_off toggle with optional switch/lights args Apr 8, 2023
@th3w1zard1 th3w1zard1 changed the title New service calls turn_on turn_off toggle with optional switch/lights args New services turn_on turn_off toggle with optional switch/lights args Apr 8, 2023
@th3w1zard1 th3w1zard1 changed the title New services turn_on turn_off toggle with optional switch/lights args New services adaptive_lighting.turn_on turn_off toggle with optional switch/lights args Apr 8, 2023
@th3w1zard1
Copy link
Collaborator Author

pre-commit's function too complex is driving me up the wall. It passes the Pytest for Pete's sake!

@th3w1zard1
Copy link
Collaborator Author

@basnijholt Hello. Could you take a look at this PR if you find the time? Thanks.


`adaptive_lighting.turn_on`, `adaptive_lighting.turn_off`, `adaptive_lighting.toggle` turn Adaptive Lighting on or off.

TODO: ...
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@th3w1zard1 could you add an explaination about what these methods can be used for?

Even I do not understand at the moment why adaptive_lighting.apply couldn't do most of these things 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure no worries. The main problem with AL's switches are the fact that they need to be referenced by name and not the light

With this PR we use the new format you've introduced in 1.10.1 to allow even more flexibility

I have each individual light on their own individual switch. My main use case is turning off the sleep switches when My alarm goes off. With this I can pass the light ids.

Before this I had to use a naming scheme where each switch is light.adaptive_lighting_al_my_light_entity. Then i had to learn Jinja, and substring the adaptive_lighting_al to get my switch. I have a complete tutorial on my fork's README.md if you'd like more info

This pr saves about 5 actions per script in my env

I look forward to hearing your alternatives to this!

@@ -201,6 +206,19 @@
'documented defaults), or "configuration" (reverts to switch config defaults). ⚙️'
)

CONF_WHICH_SWITCH, DEFAULT_WHICH_SWITCH = "switch_type", "main"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine that "main" is not available in 99% of the installations. Should we have no default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds like a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom turn_on & turn_off services
2 participants