Skip to content

Commit

Permalink
Add light transition option (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmatte authored Nov 6, 2020
1 parent 2fb6b20 commit 254980c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ media_lights_sync:
| `ha_url` | True | string | `None` | The URL to your Home Assistant. Only useful if `photo_attribute` is a relative URL<sup id="ha-url">[1](#ha-url-note)</sup>. Examples: `https://my-ha.duckdns.org`, `http://192.168.1.123:8123`. |
| `use_saturated_colors` | True | string | `False` | Increase the saturation and brightness of the colors. |
| `use_current_brightness` | True | string | `False` | Do not change lights brightness. If `False`, it will always sets all lights to maximum brightness. |
| `transition` | True | number | `None` | Number that represents the time (in seconds) the light should take to transition to the new state. |
| `condition` | True | object | | Sync lights only if the state of the condition entity is valid. |
| `condition.entity` | False | string | | The entity_id of the condition. |
| `condition.state` | False | string | | The state to match in order for the lights to sync. |
Expand Down
3 changes: 3 additions & 0 deletions apps/media_lights_sync/media_lights_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def initialize(self):
self.ha_url = self.args.get("ha_url", None)
self.use_current_brightness = self.args.get("use_current_brightness", False)
self.condition = self.args.get("condition")
self.transition = self.args.get("transition", None)
self.lights = self.args["lights"]
self.use_saturated_colors = self.args.get("use_saturated_colors", False)

Expand All @@ -42,6 +43,8 @@ def set_light_rgb(self, light, color):
light_kwargs["rgb_color"] = self.get_saturated_color(color)
if not self.use_current_brightness:
light_kwargs["brightness"] = 255
if self.transition is not None:
light_kwargs["transition"] = self.transition
self.turn_on(light, **light_kwargs)

def get_saturated_color(self, color):
Expand Down
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ media_lights_sync:
| `ha_url` | True | string | `None` | The URL to your Home Assistant. Only useful if `photo_attribute` is a relative URL<sup id="ha-url">[1](#ha-url-note)</sup>. Examples: `https://my-ha.duckdns.org`, `http://192.168.1.123:8123`. |
| `use_saturated_colors` | True | string | `False` | Increase the saturation and brightness of the colors. |
| `use_current_brightness` | True | string | `False` | Do not change lights brightness. If `False`, it will always sets all lights to maximum brightness. |
| `transition` | True | number | `None` | Number that represents the time (in seconds) the light should take to transition to the new state. |
| `condition` | True | object | | Sync lights only if the state of the condition entity is valid. |
| `condition.entity` | False | string | | The entity_id of the condition. |
| `condition.state` | False | string | | The state to match in order for the lights to sync. |
Expand Down

0 comments on commit 254980c

Please sign in to comment.