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
27eede72
Commit
27eede72
authored
6 years ago
by
Nikolay Kasyanov
Committed by
Fabian Affolter
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unique_id to mqtt_json light (#16721)
Applies changes from #16303 to mqtt_json component. Fixes #16600.
parent
258beb9c
Branches
Branches containing commit
Tags
v0.10.37
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/light/mqtt_json.py
+12
-3
12 additions, 3 deletions
homeassistant/components/light/mqtt_json.py
with
12 additions
and
3 deletions
homeassistant/components/light/mqtt_json.py
+
12
−
3
View file @
27eede72
...
@@ -53,6 +53,7 @@ CONF_EFFECT_LIST = 'effect_list'
...
@@ -53,6 +53,7 @@ CONF_EFFECT_LIST = 'effect_list'
CONF_FLASH_TIME_LONG
=
'
flash_time_long
'
CONF_FLASH_TIME_LONG
=
'
flash_time_long
'
CONF_FLASH_TIME_SHORT
=
'
flash_time_short
'
CONF_FLASH_TIME_SHORT
=
'
flash_time_short
'
CONF_HS
=
'
hs
'
CONF_HS
=
'
hs
'
CONF_UNIQUE_ID
=
'
unique_id
'
# Stealing some of these from the base MQTT configs.
# Stealing some of these from the base MQTT configs.
PLATFORM_SCHEMA
=
PLATFORM_SCHEMA
.
extend
({
PLATFORM_SCHEMA
=
PLATFORM_SCHEMA
.
extend
({
...
@@ -67,6 +68,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
...
@@ -67,6 +68,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol
.
Optional
(
CONF_FLASH_TIME_LONG
,
default
=
DEFAULT_FLASH_TIME_LONG
):
vol
.
Optional
(
CONF_FLASH_TIME_LONG
,
default
=
DEFAULT_FLASH_TIME_LONG
):
cv
.
positive_int
,
cv
.
positive_int
,
vol
.
Optional
(
CONF_NAME
,
default
=
DEFAULT_NAME
):
cv
.
string
,
vol
.
Optional
(
CONF_NAME
,
default
=
DEFAULT_NAME
):
cv
.
string
,
vol
.
Optional
(
CONF_UNIQUE_ID
):
cv
.
string
,
vol
.
Optional
(
CONF_OPTIMISTIC
,
default
=
DEFAULT_OPTIMISTIC
):
cv
.
boolean
,
vol
.
Optional
(
CONF_OPTIMISTIC
,
default
=
DEFAULT_OPTIMISTIC
):
cv
.
boolean
,
vol
.
Optional
(
CONF_QOS
,
default
=
mqtt
.
DEFAULT_QOS
):
vol
.
Optional
(
CONF_QOS
,
default
=
mqtt
.
DEFAULT_QOS
):
vol
.
All
(
vol
.
Coerce
(
int
),
vol
.
In
([
0
,
1
,
2
])),
vol
.
All
(
vol
.
Coerce
(
int
),
vol
.
In
([
0
,
1
,
2
])),
...
@@ -87,6 +89,7 @@ async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
...
@@ -87,6 +89,7 @@ async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
config
=
PLATFORM_SCHEMA
(
discovery_info
)
config
=
PLATFORM_SCHEMA
(
discovery_info
)
async_add_entities
([
MqttJson
(
async_add_entities
([
MqttJson
(
config
.
get
(
CONF_NAME
),
config
.
get
(
CONF_NAME
),
config
.
get
(
CONF_UNIQUE_ID
),
config
.
get
(
CONF_EFFECT_LIST
),
config
.
get
(
CONF_EFFECT_LIST
),
{
{
key
:
config
.
get
(
key
)
for
key
in
(
key
:
config
.
get
(
key
)
for
key
in
(
...
@@ -120,14 +123,15 @@ async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
...
@@ -120,14 +123,15 @@ async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
class
MqttJson
(
MqttAvailability
,
Light
):
class
MqttJson
(
MqttAvailability
,
Light
):
"""
Representation of a MQTT JSON light.
"""
"""
Representation of a MQTT JSON light.
"""
def
__init__
(
self
,
name
,
effect_list
,
topic
,
qos
,
retain
,
optimistic
,
def
__init__
(
self
,
name
,
unique_id
,
effect_list
,
topic
,
qos
,
retain
,
brightness
,
color_temp
,
effect
,
rgb
,
white_value
,
xy
,
hs
,
optimistic
,
brightness
,
color_temp
,
effect
,
rgb
,
white_value
,
flash_times
,
availability_topic
,
payload_available
,
xy
,
hs
,
flash_times
,
availability_topic
,
payload_available
,
payload_not_available
,
brightness_scale
):
payload_not_available
,
brightness_scale
):
"""
Initialize MQTT JSON light.
"""
"""
Initialize MQTT JSON light.
"""
super
().
__init__
(
availability_topic
,
qos
,
payload_available
,
super
().
__init__
(
availability_topic
,
qos
,
payload_available
,
payload_not_available
)
payload_not_available
)
self
.
_name
=
name
self
.
_name
=
name
self
.
_unique_id
=
unique_id
self
.
_effect_list
=
effect_list
self
.
_effect_list
=
effect_list
self
.
_topic
=
topic
self
.
_topic
=
topic
self
.
_qos
=
qos
self
.
_qos
=
qos
...
@@ -316,6 +320,11 @@ class MqttJson(MqttAvailability, Light):
...
@@ -316,6 +320,11 @@ class MqttJson(MqttAvailability, Light):
"""
Return the name of the device if any.
"""
"""
Return the name of the device if any.
"""
return
self
.
_name
return
self
.
_name
@property
def
unique_id
(
self
):
"""
Return a unique ID.
"""
return
self
.
_unique_id
@property
@property
def
is_on
(
self
):
def
is_on
(
self
):
"""
Return true if device is on.
"""
"""
Return true if device is on.
"""
...
...
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