Skip to content

Add effect service to WLED integration#33026

Merged
balloob merged 2 commits into
devfrom
frenck-2020-0304
Mar 23, 2020
Merged

Add effect service to WLED integration#33026
balloob merged 2 commits into
devfrom
frenck-2020-0304

Conversation

@frenck
Copy link
Copy Markdown
Member

@frenck frenck commented Mar 20, 2020

Proposed change

Adds a wled.effect service to the WLED integration.

This allows the user to finetune the effects running on the WLED light (or set the light into a specific effect state, before turning it on.

Allows controlling:

  • The effect (using an effect name or ID)
  • The speed of the effect
  • The intensity of the effect
  • Reverse the effect

Additionally, the reverse attribute has been added to the light (since I figured it would be helpful if one could see the current state if one could set it.)

Tests are added to keep the full coverage:

----------- coverage: platform linux, python 3.7.6-final-0 -----------
Name                                           Stmts   Miss  Cover
------------------------------------------------------------------
homeassistant/components/wled/__init__.py         97      0   100%
homeassistant/components/wled/config_flow.py      56      0   100%
homeassistant/components/wled/const.py            22      0   100%
homeassistant/components/wled/light.py           110      0   100%
homeassistant/components/wled/sensor.py           51      0   100%
homeassistant/components/wled/switch.py           66      0   100%
------------------------------------------------------------------
TOTAL                                            402      0   100%
Coverage XML written to file cov.xml


Results (1.83s):
      28 passed

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example automation

# Example automation
automation:
  - alias: Alarm system
    trigger:
      platform: state
      entity_id: binary_sensor.motion_buglar
      to: 'on'
    condition: []
    action:
      - service: wled.effect
        entity_id: light.wled
        data:
          effect: police
          intensity: 255
          speed: 255
          reverse: true
      - service: light.turn_on
        entity_id: light.wled

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@frenck
Copy link
Copy Markdown
Member Author

frenck commented Mar 20, 2020

Documentation PR created. Marked this PR ready for review.

ATTR_PALETTE = "palette"
ATTR_PLAYLIST = "playlist"
ATTR_PRESET = "preset"
ATTR_REVERSE = "reverse"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be called effect_reverse to make it clear what is being reversed ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The same can be said about speed for example.
I kept it consistent with that and the way it is used/displayed in WLED itself, just to stay close with that.

Comment thread homeassistant/components/wled/light.py Outdated
@frenck frenck force-pushed the frenck-2020-0304 branch from ae1a93f to 272d576 Compare March 23, 2020 10:32
@frenck
Copy link
Copy Markdown
Member Author

frenck commented Mar 23, 2020

Rebased PR onto the latest dev to deal with the merge conflict.

@balloob balloob merged commit 513abcb into dev Mar 23, 2020
@balloob balloob deleted the frenck-2020-0304 branch March 23, 2020 20:21
@lock lock Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants