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
18883118
Unverified
Commit
18883118
authored
1 year ago
by
David Knowles
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Hydrawise: Explicitly set switch state on toggle (#103827)
Explicitly set switch state on toggle
parent
64c9aa0c
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/hydrawise/switch.py
+4
-0
4 additions, 0 deletions
homeassistant/components/hydrawise/switch.py
tests/components/hydrawise/test_switch.py
+12
-0
12 additions, 0 deletions
tests/components/hydrawise/test_switch.py
with
16 additions
and
0 deletions
homeassistant/components/hydrawise/switch.py
+
4
−
0
View file @
18883118
...
...
@@ -114,6 +114,8 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
self
.
coordinator
.
api
.
run_zone
(
self
.
_default_watering_timer
,
zone_number
)
elif
self
.
entity_description
.
key
==
"
auto_watering
"
:
self
.
coordinator
.
api
.
suspend_zone
(
0
,
zone_number
)
self
.
_attr_is_on
=
True
self
.
async_write_ha_state
()
def
turn_off
(
self
,
**
kwargs
:
Any
)
->
None
:
"""
Turn the device off.
"""
...
...
@@ -122,6 +124,8 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
self
.
coordinator
.
api
.
run_zone
(
0
,
zone_number
)
elif
self
.
entity_description
.
key
==
"
auto_watering
"
:
self
.
coordinator
.
api
.
suspend_zone
(
365
,
zone_number
)
self
.
_attr_is_on
=
False
self
.
async_write_ha_state
()
def
_update_attrs
(
self
)
->
None
:
"""
Update state attributes.
"""
...
...
This diff is collapsed.
Click to expand it.
tests/components/hydrawise/test_switch.py
+
12
−
0
View file @
18883118
...
...
@@ -45,6 +45,9 @@ async def test_manual_watering_services(
blocking
=
True
,
)
mock_pydrawise
.
run_zone
.
assert_called_once_with
(
15
,
1
)
state
=
hass
.
states
.
get
(
"
switch.zone_one_manual_watering
"
)
assert
state
is
not
None
assert
state
.
state
==
"
on
"
mock_pydrawise
.
reset_mock
()
await
hass
.
services
.
async_call
(
...
...
@@ -54,6 +57,9 @@ async def test_manual_watering_services(
blocking
=
True
,
)
mock_pydrawise
.
run_zone
.
assert_called_once_with
(
0
,
1
)
state
=
hass
.
states
.
get
(
"
switch.zone_one_manual_watering
"
)
assert
state
is
not
None
assert
state
.
state
==
"
off
"
async
def
test_auto_watering_services
(
...
...
@@ -67,6 +73,9 @@ async def test_auto_watering_services(
blocking
=
True
,
)
mock_pydrawise
.
suspend_zone
.
assert_called_once_with
(
365
,
1
)
state
=
hass
.
states
.
get
(
"
switch.zone_one_automatic_watering
"
)
assert
state
is
not
None
assert
state
.
state
==
"
off
"
mock_pydrawise
.
reset_mock
()
await
hass
.
services
.
async_call
(
...
...
@@ -76,3 +85,6 @@ async def test_auto_watering_services(
blocking
=
True
,
)
mock_pydrawise
.
suspend_zone
.
assert_called_once_with
(
0
,
1
)
state
=
hass
.
states
.
get
(
"
switch.zone_one_automatic_watering
"
)
assert
state
is
not
None
assert
state
.
state
==
"
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