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
f50325fc
Unverified
Commit
f50325fc
authored
1 month ago
by
Luke Lashley
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Add dock dryer control to Roborock (#138495)
* Add a dock dryer select * change import * Change name to match app
parent
0b41d056
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/roborock/select.py
+30
-17
30 additions, 17 deletions
homeassistant/components/roborock/select.py
homeassistant/components/roborock/strings.json
+9
-0
9 additions, 0 deletions
homeassistant/components/roborock/strings.json
with
39 additions
and
17 deletions
homeassistant/components/roborock/select.py
+
30
−
17
View file @
f50325fc
...
...
@@ -4,9 +4,9 @@ import asyncio
from
collections.abc
import
Callable
from
dataclasses
import
dataclass
from
roborock.co
ntainers
import
Status
from
roborock.co
de_mappings
import
RoborockDockDustCollectionModeCode
from
roborock.roborock_message
import
RoborockDataProtocol
from
roborock.roborock_typing
import
RoborockCommand
from
roborock.roborock_typing
import
DeviceProp
,
RoborockCommand
from
homeassistant.components.select
import
SelectEntity
,
SelectEntityDescription
from
homeassistant.const
import
EntityCategory
...
...
@@ -25,11 +25,11 @@ class RoborockSelectDescription(SelectEntityDescription):
# The command that the select entity will send to the api.
api_command
:
RoborockCommand
# Gets the current value of the select entity.
value_fn
:
Callable
[[
Status
],
str
|
None
]
value_fn
:
Callable
[[
DeviceProp
],
str
|
None
]
# Gets all options of the select entity.
options_lambda
:
Callable
[[
Status
],
list
[
str
]
|
None
]
options_lambda
:
Callable
[[
DeviceProp
],
list
[
str
]
|
None
]
# Takes the value from the select entity and converts it for the api.
parameter_lambda
:
Callable
[[
str
,
Status
],
list
[
int
]]
parameter_lambda
:
Callable
[[
str
,
DeviceProp
],
list
[
int
]]
protocol_listener
:
RoborockDataProtocol
|
None
=
None
...
...
@@ -39,24 +39,37 @@ SELECT_DESCRIPTIONS: list[RoborockSelectDescription] = [
key
=
"
water_box_mode
"
,
translation_key
=
"
mop_intensity
"
,
api_command
=
RoborockCommand
.
SET_WATER_BOX_CUSTOM_MODE
,
value_fn
=
lambda
data
:
data
.
water_box_mode_name
,
value_fn
=
lambda
data
:
data
.
status
.
water_box_mode_name
,
entity_category
=
EntityCategory
.
CONFIG
,
options_lambda
=
lambda
data
:
data
.
water_box_mode
.
keys
()
if
data
.
water_box_mode
is
not
None
options_lambda
=
lambda
data
:
data
.
status
.
water_box_mode
.
keys
()
if
data
.
status
.
water_box_mode
is
not
None
else
None
,
parameter_lambda
=
lambda
key
,
status
:
[
status
.
get_mop_intensity_code
(
key
)],
parameter_lambda
=
lambda
key
,
prop
:
[
prop
.
status
.
get_mop_intensity_code
(
key
)],
protocol_listener
=
RoborockDataProtocol
.
WATER_BOX_MODE
,
),
RoborockSelectDescription
(
key
=
"
mop_mode
"
,
translation_key
=
"
mop_mode
"
,
api_command
=
RoborockCommand
.
SET_MOP_MODE
,
value_fn
=
lambda
data
:
data
.
mop_mode_name
,
value_fn
=
lambda
data
:
data
.
status
.
mop_mode_name
,
entity_category
=
EntityCategory
.
CONFIG
,
options_lambda
=
lambda
data
:
data
.
mop_mode
.
keys
()
if
data
.
mop_mode
is
not
None
options_lambda
=
lambda
data
:
data
.
status
.
mop_mode
.
keys
()
if
data
.
status
.
mop_mode
is
not
None
else
None
,
parameter_lambda
=
lambda
key
,
status
:
[
status
.
get_mop_mode_code
(
key
)],
parameter_lambda
=
lambda
key
,
prop
:
[
prop
.
status
.
get_mop_mode_code
(
key
)],
),
RoborockSelectDescription
(
key
=
"
dust_collection_mode
"
,
translation_key
=
"
dust_collection_mode
"
,
api_command
=
RoborockCommand
.
SET_DUST_COLLECTION_MODE
,
value_fn
=
lambda
data
:
data
.
dust_collection_mode_name
,
entity_category
=
EntityCategory
.
CONFIG
,
options_lambda
=
lambda
data
:
RoborockDockDustCollectionModeCode
.
keys
()
if
data
.
dust_collection_mode_name
is
not
None
else
None
,
parameter_lambda
=
lambda
key
,
_
:
[
RoborockDockDustCollectionModeCode
.
as_dict
().
get
(
key
)
],
),
]
...
...
@@ -74,7 +87,7 @@ async def async_setup_entry(
for
description
in
SELECT_DESCRIPTIONS
if
(
options
:
=
description
.
options_lambda
(
coordinator
.
roborock_device_info
.
props
.
status
coordinator
.
roborock_device_info
.
props
)
)
is
not
None
...
...
@@ -111,13 +124,13 @@ class RoborockSelectEntity(RoborockCoordinatedEntityV1, SelectEntity):
"""
Set the option.
"""
await
self
.
send
(
self
.
entity_description
.
api_command
,
self
.
entity_description
.
parameter_lambda
(
option
,
self
.
_device_status
),
self
.
entity_description
.
parameter_lambda
(
option
,
self
.
coordinator
.
data
),
)
@property
def
current_option
(
self
)
->
str
|
None
:
"""
Get the current status of the select entity from device
_statu
s.
"""
return
self
.
entity_description
.
value_fn
(
self
.
_device_status
)
"""
Get the current status of the select entity from device
prop
s.
"""
return
self
.
entity_description
.
value_fn
(
self
.
coordinator
.
data
)
class
RoborockCurrentMapSelectEntity
(
RoborockCoordinatedEntityV1
,
SelectEntity
):
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/roborock/strings.json
+
9
−
0
View file @
f50325fc
...
...
@@ -353,6 +353,15 @@
},
"selected_map"
:
{
"name"
:
"Selected map"
},
"dust_collection_mode"
:
{
"name"
:
"Empty mode"
,
"state"
:
{
"smart"
:
"Smart"
,
"light"
:
"Light"
,
"balanced"
:
"[%key:component::roborock::entity::vacuum::roborock::state_attributes::fan_speed::state::balanced%]"
,
"max"
:
"[%key:component::roborock::entity::select::mop_intensity::state::max%]"
}
}
},
"switch"
:
{
...
...
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