Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
f20a81d0
Commit
f20a81d0
authored
7 years ago
by
Gergely Imreh
Committed by
Paulus Schoutsen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
light.blinkt: add support for Blinkt! lights on Raspberry Pi (#7377)
parent
9afbbbf3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.coveragerc
+1
-0
1 addition, 0 deletions
.coveragerc
homeassistant/components/light/blinkt.py
+120
-0
120 additions, 0 deletions
homeassistant/components/light/blinkt.py
requirements_all.txt
+3
-0
3 additions, 0 deletions
requirements_all.txt
with
124 additions
and
0 deletions
.coveragerc
+
1
−
0
View file @
f20a81d0
...
@@ -231,6 +231,7 @@ omit =
...
@@ -231,6 +231,7 @@ omit =
homeassistant/components/keyboard.py
homeassistant/components/keyboard.py
homeassistant/components/keyboard_remote.py
homeassistant/components/keyboard_remote.py
homeassistant/components/light/avion.py
homeassistant/components/light/avion.py
homeassistant/components/light/blinkt.py
homeassistant/components/light/blinksticklight.py
homeassistant/components/light/blinksticklight.py
homeassistant/components/light/decora.py
homeassistant/components/light/decora.py
homeassistant/components/light/flux_led.py
homeassistant/components/light/flux_led.py
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/light/blinkt.py
0 → 100644
+
120
−
0
View file @
f20a81d0
"""
Support for Blinkt! lights on Raspberry Pi.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.blinkt/
"""
import
logging
import
voluptuous
as
vol
import
homeassistant.helpers.config_validation
as
cv
from
homeassistant.components.light
import
(
ATTR_BRIGHTNESS
,
SUPPORT_BRIGHTNESS
,
ATTR_RGB_COLOR
,
SUPPORT_RGB_COLOR
,
Light
,
PLATFORM_SCHEMA
)
from
homeassistant.const
import
CONF_NAME
REQUIREMENTS
=
[
'
blinkt==0.1.0
'
]
_LOGGER
=
logging
.
getLogger
(
__name__
)
SUPPORT_BLINKT
=
(
SUPPORT_BRIGHTNESS
|
SUPPORT_RGB_COLOR
)
DEFAULT_NAME
=
'
blinkt
'
PLATFORM_SCHEMA
=
PLATFORM_SCHEMA
.
extend
({
vol
.
Optional
(
CONF_NAME
,
default
=
DEFAULT_NAME
):
cv
.
string
,
})
def
setup_platform
(
hass
,
config
,
add_devices
,
discovery_info
=
None
):
"""
Set up the Blinkt Light platform.
"""
import
blinkt
# ensure that the lights are off when exiting
blinkt
.
set_clear_on_exit
()
name
=
config
.
get
(
CONF_NAME
)
add_devices
([
BlinktLight
(
blinkt
,
name
)])
class
BlinktLight
(
Light
):
"""
Representation of a Blinkt! Light.
"""
def
__init__
(
self
,
blinkt
,
name
):
"""
Initialize a Blinkt Light.
Default brightness and white color.
"""
self
.
_blinkt
=
blinkt
self
.
_name
=
name
self
.
_is_on
=
False
self
.
_brightness
=
255
self
.
_rgb_color
=
[
255
,
255
,
255
]
@property
def
name
(
self
):
"""
Return the display name of this light.
"""
return
self
.
_name
@property
def
brightness
(
self
):
"""
Read back the brightness of the light.
Returns integer in the range of 1-255.
"""
return
self
.
_brightness
@property
def
rgb_color
(
self
):
"""
Read back the color of the light.
Returns [r, g, b] list with values in range of 0-255.
"""
return
self
.
_rgb_color
@property
def
supported_features
(
self
):
"""
Flag supported features.
"""
return
SUPPORT_BLINKT
@property
def
is_on
(
self
):
"""
Return true if light is on.
"""
return
self
.
_is_on
@property
def
should_poll
(
self
):
"""
Return if we should poll this device.
"""
return
False
@property
def
assumed_state
(
self
)
->
bool
:
"""
Return True if unable to access real state of the entity.
"""
return
True
def
turn_on
(
self
,
**
kwargs
):
"""
Instruct the light to turn on and set correct brightness & color.
"""
self
.
_brightness
=
kwargs
.
get
(
ATTR_BRIGHTNESS
,
255
)
percent_bright
=
(
self
.
_brightness
/
255
)
if
ATTR_RGB_COLOR
in
kwargs
:
self
.
_rgb_color
=
kwargs
[
ATTR_RGB_COLOR
]
self
.
_blinkt
.
set_all
(
self
.
_rgb_color
[
0
],
self
.
_rgb_color
[
1
],
self
.
_rgb_color
[
2
],
percent_bright
)
self
.
_blinkt
.
show
()
self
.
_is_on
=
True
self
.
schedule_update_ha_state
()
def
turn_off
(
self
,
**
kwargs
):
"""
Instruct the light to turn off.
"""
self
.
_blinkt
.
set_brightness
(
0
)
self
.
_blinkt
.
show
()
self
.
_is_on
=
False
self
.
schedule_update_ha_state
()
This diff is collapsed.
Click to expand it.
requirements_all.txt
+
3
−
0
View file @
f20a81d0
...
@@ -92,6 +92,9 @@ blinkpy==0.5.2
...
@@ -92,6 +92,9 @@ blinkpy==0.5.2
# homeassistant.components.light.blinksticklight
# homeassistant.components.light.blinksticklight
blinkstick==1.1.8
blinkstick==1.1.8
# homeassistant.components.light.blinkt
blinkt==0.1.0
# homeassistant.components.sensor.bitcoin
# homeassistant.components.sensor.bitcoin
blockchain==1.3.3
blockchain==1.3.3
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment