Skip to content

Add lightbulb option #66

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add lightbulb option #66

wants to merge 8 commits into from

Conversation

Idomo
Copy link

@Idomo Idomo commented Jan 1, 2023

This is an adjustment for #44 that updated for the latest version of this plugin and allows more flexibility.

This lets us adjusting the percentage of the lightbulb as per the number of units we want the timer to work.
When setting "actAsBulb": true, the delay becomes the unit (e.g. "delay": 1000 = 1 second, "delay": 60000 = 1 minute) that will be multiply by the percentage of the lightbulb.

This is very useful for adding timers via Siri Shortcuts that requires delay that the user choosing on each activation of the shortcut (e.g. "turn on boiler for X minuets" may differ depends on the current temperature, how long is the shower etc.)

Idomo added 3 commits January 1, 2023 15:31
This lets us adjusting the percentage of the lightbulb as per the number of units we want the timer to work.
When setting `"actAsBulb": true`, the delay becomes the unit (e.g. `"delay": 1000` = 1 second, `"delay": 60000` = 1 minute) that will be multiply by the percentage of the lightbulb.
This lets us adjusting the percentage of the lightbulb as per the number of units we want the timer to work.
When setting `"actAsBulb": true`, the delay becomes the unit (e.g. `"delay": 1000` = 1 second, `"delay": 60000` = 1 minute) that will be multiply by the percentage of the lightbulb.
@nitaybz
Copy link
Owner

nitaybz commented Dec 22, 2023

I'll merge if it will be adapter to recent changes in the main branch

@Idomo
Copy link
Author

Idomo commented Dec 22, 2023

@nitaybz The conflicts has been resolved.

@nitaybz
Copy link
Owner

nitaybz commented Dec 23, 2023

sorry but i made some minor updates that will require conflicts to be resolved.
also, I think a better approach for the lightbulb to be as following:

  1. the delay time you set is 100% and than you can choose to activate it for 50% of the normal time. so for example I can set the delay time for 2 hours and then set the boiler to be active for 30 minutes or 1 hour by setting the bulb to 25-50%.
  2. what's really nice about this method (as mentioned in point 1) is the following advantage. the brightness percentage should represent the remaining time. so if i'm continuing the previous example, I would turn the boiler for 2 hours and after 1 hour I would be able to see that the brightness is on 50%.

To sum it up, I think a great representation of a lightbulb in this plugin would be to both allow activating the timer for part of the time while also understanding how much time left by looking at the percentage of the brightness.

Let me know you thoughts, thanks

@mkz212
Copy link

mkz212 commented Dec 23, 2023

@nitaybz I think the method presented by @Idomo is better and simpler.

  • Example 1:
    You set delay to 1 and delayUnit to minutes - then setting light to 10 you have 10 minutes of countdown

  • Example 2:
    You set delay to 10 and delayUnit to seconds - then setting light to 30 you have 300 seconds of countdown

The basic timer unit is currently given in Model name. So, for example, 5 seconds. Then it is known that if you set 10 units it will be 50 seconds.

@nitaybz
Copy link
Owner

nitaybz commented Dec 23, 2023

The issue with it is that in HomeKit it's extremely hard to set a very specific percentage, for example 1% almost impossible.

I rather have the 100% as the delay and the ability to activate partially

@mkz212
Copy link

mkz212 commented Dec 23, 2023

The issue with it is that in HomeKit it's extremely hard to set a very specific percentage, for example 1% almost impossible.

I rather have the 100% as the delay and the ability to activate partially

But this is mainly for automation - there you set it only once. Or to control with Siri. I still find @Idomo's solution better and simpler!

@mkz212
Copy link

mkz212 commented Dec 23, 2023

  • You choose a unit: milliseconds, seconds, minutes, hours, days.
  • you set the timer from 1 to 100 and that's it.

@Idomo
Copy link
Author

Idomo commented Dec 23, 2023

@nitaybz I understand your perspective, but it's limiting the timer to a specific time that has to be defined in the HomeBridge settings, and this is what @mkz212 is trying to explain here;
You want to have the ability to set dynamic timers for different automations or even via Siri commands and with that you would "bypass" the limitation of having to define hardcoded delay in the plugin's settings.

If you need only one specific time then you can always define a unit that will be divided by 100 and go with your approach, but it isn't the original intention here.

About the conflicts - I see that you just ran ESLint, so please revert this commit, merge my pull request and run it again (so it'll also be applied on the new code).

@mkz212
Copy link

mkz212 commented Dec 23, 2023

@nitaybz I suggest to give it a try and release @Idomo solution as a beta and we'll see.

But I would change one thing right away. Instead of Bool - one of - i.e. the choice of type - switch, light. This will be useful if you add another type in the future. For example, you can immediately add an outlet as another type.

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

Successfully merging this pull request may close these issues.

3 participants