Commit graph

56 commits

Author SHA1 Message Date
Bas Nijholt
643d69bbf8 do is sleep logging in is_sleep method 2020-08-25 18:45:10 +02:00
Bas Nijholt
3ea906ea2e use comment when inline 2020-08-25 18:43:07 +02:00
Bas Nijholt
8a49a6fe87 use extend instead of += 2020-08-25 18:41:58 +02:00
Bas Nijholt
38dc367c56 simplify adjust_lights even more 2020-08-25 18:39:13 +02:00
Bas Nijholt
34c4fdb71a don't run if statements that will never run 2020-08-25 18:30:08 +02:00
Bas Nijholt
e381d0c0e3 simplify conditions in adjust_lights 2020-08-25 18:27:48 +02:00
Bas Nijholt
97598cfaac reduce indentation of adjust_lights 2020-08-25 18:26:00 +02:00
Bas Nijholt
56a5a49f64 simplify calc_brightness 2020-08-25 18:23:12 +02:00
Bas Nijholt
8605578301 more simplifications 2020-08-25 18:21:48 +02:00
Bas Nijholt
5f1c7ad827 remove unused import 2020-08-25 18:18:46 +02:00
Bas Nijholt
ce7e08d824 fix last f-string 2020-08-25 18:18:21 +02:00
Bas Nijholt
26796a449d use contextlib.suppress 2020-08-25 18:17:16 +02:00
Bas Nijholt
5448caced2 use f-strings in logs 2020-08-25 18:16:20 +02:00
Bas Nijholt
f7119aebaf use 'is None' and 'is not None' 2020-08-25 18:10:41 +02:00
Bas Nijholt
9b8a4ad51f run black, pyupgrade, and isort 2020-08-25 18:08:33 +02:00
Clayton Nummer
ff4854e7b7 Version bump for master 2020-06-11 13:09:31 -04:00
Clayton Nummer
976a35e109
Merge branch 'dev' into master 2020-06-03 21:05:42 -04:00
LJU
a2a1c45744
Update switch.py 2020-05-22 23:36:45 +02:00
LJU
836e2922a6
Update with try 2020-05-22 23:36:16 +02:00
LJU
5f3700343b
Update import
Update import and add switchdevice for earlier versions
2020-05-21 15:33:49 +02:00
LJU
d7c27cd107
Update SwitchDevice to SwitchEntity 2020-05-14 08:28:41 +02:00
LJU
eaa5c0e3dd
Update SwitchDevice to SwitchEntity 2020-05-14 08:26:29 +02:00
Clayton Nummer
498da0e0db Use actual timezone to fix configured sunrise/sunset 2020-03-19 17:25:02 -04:00
Clayton Nummer
03718f0e3c Version bump for (deprecated) custom updater 2020-03-19 15:49:30 -04:00
Clayton Nummer
9e1d140e19 Use the same timezone for "now" time and configured lat/long 2020-03-19 15:48:52 -04:00
Clayton Nummer
4909fdbdd5
Merge pull request #76 from claytonjn/dev
Use HA defined VALID_TRANSITION for initial transition
2020-03-07 10:32:48 -05:00
Clayton Nummer
3fb9fcc9c3 Use HA defined VALID_TRANSITION for initial transition
rather than defining our own
2020-03-07 10:31:52 -05:00
Clayton Nummer
abe47adc86 Version bump for (deprecated) custom updater 2020-03-07 10:16:13 -05:00
Clayton Nummer
6c26f5dbe1 Version bump for (deprecated) custom updater 2020-02-21 22:16:31 -05:00
Clayton Nummer
5e167bef82
Merge pull request #70 from mouth4war/init-trans
Initial transition configurable and defaulted
2020-02-21 22:11:21 -05:00
Clayton Nummer
61741f6501
Fix getting initial transition from config 2020-02-21 22:05:08 -05:00
mouth4war
05f98fa673
Initial transition configurable and defaulted 2020-02-20 15:22:07 +05:30
Clayton Nummer
db7d0574dd Bump version for services hotfix, and fix typo 2020-02-12 23:04:10 -05:00
Kevin T. Berstene
c2b0ef0e3b Fixed services to conform to Home Assistant specs 2020-02-12 22:06:08 -05:00
Clayton Nummer
ca4b4fc7bd Exemption handling
Handles some unexpected state behavior
2019-08-04 15:15:33 -04:00
Clayton Nummer
abc151601b Adjust lights immediately when disable entity state changes
I'm thinking about removing the disable entity option, but while it remains this is the proper behavior
2019-08-04 14:49:14 -04:00
Clayton Nummer
be01be243d Define "initial transition" and use it when CL switch is turned on
A 1 sec transition was used when a light is turned on or when sleep state changes. The short transition should also be used when the CL switch is turned on. Also, because this is used in multiple spots, better to define it in one spot (this will also make it easier to make it configurable, if desired)
2019-08-04 14:16:59 -04:00
Clayton Nummer
7185fe3feb Only react to light state change to 'on'
And only when light isn't already on. This should allow for users to disable CL when they adjust a light from the frontend, without CL immediately readjusting. This also should remove the need for checking state of each light before adjusting, because infinite loops should no longer trigger.
2019-07-31 14:53:34 -04:00
Clayton Nummer
6dcd192f4e Bump version number 2019-07-30 18:25:42 -04:00
Clayton Nummer
14f272e8cd Change brightness scale to max at 254
Supposedly the max light brightness is 255, but my Hue and Lightify lights both max at 254. 0 turns off the light, so the range is probably (0, 255) not [0, 255]
2019-07-30 18:25:02 -04:00
Clayton Nummer
40568296ed Slight efficiency tweaks
Don't calculate values for every light, and only set service_data if it's going to be used
2019-07-30 17:48:33 -04:00
Clayton Nummer
36115d4fce Check light values before setting them
Hopefully this eliminates possible "infinite loop" of adjustment, where the SERVICE_TURN_ON call triggers  CL to adjust and so on.
2019-07-30 17:13:47 -04:00
Clayton Nummer
f3a1a73885 Remove configuration options from entity attributes
The biggest concern is that apparently any device_class with longitude, latitude, and elevation will show up on the HA map (not just device_tracker). In general, however, configuration options in attributes is extraneous and the community voted to remove them (https://community.home-assistant.io/t/circadian-lighting-custom-component/61246/355)
2019-06-14 16:27:28 -04:00
Clayton Nummer
6d9df861ce Tweak default interval/transition for better compatibility
Some types of lights seem to have issues with long transitions
2019-06-08 11:20:58 -04:00
Clayton Nummer
4f332a514c Re-write of values calculation
The basis of Circadian Lighting is to figure out how to adjust lights to mimic the sun, which is roughly parabolic above and below the horizon. Originally I used three points to calculate the parabolas - sunrise, sunset, and solar noon/midnight. I did a bunch of generic arithmetic to generate the parabola from those three points. The problem is that this arithmetic generates a parabola from _any_ three points - in reality the points I have are the intercepts and vertex.

The problem with the old method is that if solar noon/midnight did not fall exactly between sunrise and sunset then the calculated vertex could be more or less than 100%, which would cause the integration to set color/brightness values above or below the set min/max. Generating a parabola from the intercepts and vertex is much simpler and also should guarantee the min/max are what's expected. 

In addition to this change, I'm also now calculating 4 "half" parabolas instead of just one for above horizon and one for below horizon. The "half" parabolas are: sunrise->solar-noon, solar-noon->sunset, sunset->solar-midnight, solar-midnight->sunrise. This is necessary for the case where solar noon/midnight don't fall exactly half way between sunrise and sunset, which is especially prevalent for users who specify a specific time for sunrise or sunset but not both.

I'm embarrassed at how it's been before it dawned on me that I could calculate the parabolas from intercepts/vertex rather than the three random points method, but hopefully this fixes inconsistencies for users - it should definitely fix issue #25!
2019-06-01 14:20:47 -04:00
Clayton Nummer
34d5529a05 Increment version
for added manifest.json and services.yaml
2019-05-09 13:25:48 -04:00
Clayton Nummer
85abb4bb5b
Small tweak 2019-05-09 13:14:15 -04:00
Clayton Nummer
1f679de674
Small tweak 2019-05-09 13:13:47 -04:00
Aaron Godfrey
b3252e52a8 Added missing services.yaml 2019-05-06 07:33:23 -07:00
Aaron Godfrey
6b0a4f942b Added manifest.json 2019-05-04 09:54:32 -07:00