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
658ec309
Commit
658ec309
authored
5 years ago
by
SukramJ
Committed by
Paulus Schoutsen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add HmIP-MOD_TM to HomematicIP Cloud (#30255)
parent
c5a280c0
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/homematicip_cloud/cover.py
+40
-1
40 additions, 1 deletion
homeassistant/components/homematicip_cloud/cover.py
tests/components/homematicip_cloud/test_cover.py
+46
-0
46 additions, 0 deletions
tests/components/homematicip_cloud/test_cover.py
with
86 additions
and
1 deletion
homeassistant/components/homematicip_cloud/cover.py
+
40
−
1
View file @
658ec309
...
...
@@ -2,7 +2,12 @@
import
logging
from
typing
import
Optional
from
homematicip.aio.device
import
AsyncFullFlushBlind
,
AsyncFullFlushShutter
from
homematicip.aio.device
import
(
AsyncFullFlushBlind
,
AsyncFullFlushShutter
,
AsyncGarageDoorModuleTormatic
,
)
from
homematicip.base.enums
import
DoorCommand
,
DoorState
from
homeassistant.components.cover
import
(
ATTR_POSITION
,
...
...
@@ -40,6 +45,8 @@ async def async_setup_entry(
entities
.
append
(
HomematicipCoverSlats
(
hap
,
device
))
elif
isinstance
(
device
,
AsyncFullFlushShutter
):
entities
.
append
(
HomematicipCoverShutter
(
hap
,
device
))
elif
isinstance
(
device
,
AsyncGarageDoorModuleTormatic
):
entities
.
append
(
HomematicipGarageDoorModuleTormatic
(
hap
,
device
))
if
entities
:
async_add_entities
(
entities
)
...
...
@@ -106,3 +113,35 @@ class HomematicipCoverSlats(HomematicipCoverShutter, CoverDevice):
async
def
async_stop_cover_tilt
(
self
,
**
kwargs
)
->
None
:
"""
Stop the device if in motion.
"""
await
self
.
_device
.
set_shutter_stop
()
class
HomematicipGarageDoorModuleTormatic
(
HomematicipGenericDevice
,
CoverDevice
):
"""
Representation of a HomematicIP Garage Door Module for Tormatic.
"""
@property
def
current_cover_position
(
self
)
->
int
:
"""
Return current position of cover.
"""
door_state_to_position
=
{
DoorState
.
CLOSED
:
0
,
DoorState
.
OPEN
:
100
,
DoorState
.
VENTILATION_POSITION
:
10
,
DoorState
.
POSITION_UNKNOWN
:
None
,
}
return
door_state_to_position
.
get
(
self
.
_device
.
doorState
)
@property
def
is_closed
(
self
)
->
Optional
[
bool
]:
"""
Return if the cover is closed.
"""
return
self
.
_device
.
doorState
==
DoorState
.
CLOSED
async
def
async_open_cover
(
self
,
**
kwargs
)
->
None
:
"""
Open the cover.
"""
await
self
.
_device
.
send_door_command
(
DoorCommand
.
OPEN
)
async
def
async_close_cover
(
self
,
**
kwargs
)
->
None
:
"""
Close the cover.
"""
await
self
.
_device
.
send_door_command
(
DoorCommand
.
CLOSE
)
async
def
async_stop_cover
(
self
,
**
kwargs
)
->
None
:
"""
Stop the cover.
"""
await
self
.
_device
.
send_door_command
(
DoorCommand
.
STOP
)
This diff is collapsed.
Click to expand it.
tests/components/homematicip_cloud/test_cover.py
+
46
−
0
View file @
658ec309
"""
Tests for HomematicIP Cloud cover.
"""
from
homematicip.base.enums
import
DoorCommand
,
DoorState
from
homeassistant.components.cover
import
(
ATTR_CURRENT_POSITION
,
ATTR_CURRENT_TILT_POSITION
,
...
...
@@ -153,3 +155,47 @@ async def test_hmip_cover_slats(hass, default_mock_hap):
await
async_manipulate_test_data
(
hass
,
hmip_device
,
"
shutterLevel
"
,
None
)
ha_state
=
hass
.
states
.
get
(
entity_id
)
assert
ha_state
.
state
==
STATE_OPEN
async
def
test_hmip_garage_door_tormatic
(
hass
,
default_mock_hap
):
"""
Test HomematicipCoverShutte.
"""
entity_id
=
"
cover.garage_door_module
"
entity_name
=
"
Garage Door Module
"
device_model
=
"
HmIP-MOD-TM
"
ha_state
,
hmip_device
=
get_and_check_entity_basics
(
hass
,
default_mock_hap
,
entity_id
,
entity_name
,
device_model
)
assert
ha_state
.
state
==
"
closed
"
assert
ha_state
.
attributes
[
"
current_position
"
]
==
0
service_call_counter
=
len
(
hmip_device
.
mock_calls
)
await
hass
.
services
.
async_call
(
"
cover
"
,
"
open_cover
"
,
{
"
entity_id
"
:
entity_id
},
blocking
=
True
)
assert
len
(
hmip_device
.
mock_calls
)
==
service_call_counter
+
1
assert
hmip_device
.
mock_calls
[
-
1
][
0
]
==
"
send_door_command
"
assert
hmip_device
.
mock_calls
[
-
1
][
1
]
==
(
DoorCommand
.
OPEN
,)
await
async_manipulate_test_data
(
hass
,
hmip_device
,
"
doorState
"
,
DoorState
.
OPEN
)
ha_state
=
hass
.
states
.
get
(
entity_id
)
assert
ha_state
.
state
==
STATE_OPEN
assert
ha_state
.
attributes
[
ATTR_CURRENT_POSITION
]
==
100
await
hass
.
services
.
async_call
(
"
cover
"
,
"
close_cover
"
,
{
"
entity_id
"
:
entity_id
},
blocking
=
True
)
assert
len
(
hmip_device
.
mock_calls
)
==
service_call_counter
+
3
assert
hmip_device
.
mock_calls
[
-
1
][
0
]
==
"
send_door_command
"
assert
hmip_device
.
mock_calls
[
-
1
][
1
]
==
(
DoorCommand
.
CLOSE
,)
await
async_manipulate_test_data
(
hass
,
hmip_device
,
"
doorState
"
,
DoorState
.
CLOSED
)
ha_state
=
hass
.
states
.
get
(
entity_id
)
assert
ha_state
.
state
==
STATE_CLOSED
assert
ha_state
.
attributes
[
ATTR_CURRENT_POSITION
]
==
0
await
hass
.
services
.
async_call
(
"
cover
"
,
"
stop_cover
"
,
{
"
entity_id
"
:
entity_id
},
blocking
=
True
)
assert
len
(
hmip_device
.
mock_calls
)
==
service_call_counter
+
5
assert
hmip_device
.
mock_calls
[
-
1
][
0
]
==
"
send_door_command
"
assert
hmip_device
.
mock_calls
[
-
1
][
1
]
==
(
DoorCommand
.
STOP
,)
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