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
b7296c61
Commit
b7296c61
authored
5 years ago
by
SukramJ
Committed by
Martin Hjelmare
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Align attribute naming between light and switch for HomematicIP Cloud (#28271)
parent
552fbda5
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/light.py
+6
-6
6 additions, 6 deletions
homeassistant/components/homematicip_cloud/light.py
tests/components/homematicip_cloud/test_light.py
+4
-4
4 additions, 4 deletions
tests/components/homematicip_cloud/test_light.py
with
10 additions
and
10 deletions
homeassistant/components/homematicip_cloud/light.py
+
6
−
6
View file @
b7296c61
...
...
@@ -28,8 +28,8 @@ from .hap import HomematicipHAP
_LOGGER
=
logging
.
getLogger
(
__name__
)
ATTR_ENERGY_
COUNTER
=
"
energy_counter
_kwh
"
ATTR_
POWER_CONSUMPTION
=
"
power_consumption
"
ATTR_
TODAY_
ENERGY_
KWH
=
"
today_energy
_kwh
"
ATTR_
CURRENT_POWER_W
=
"
current_power_w
"
async
def
async_setup_platform
(
hass
,
config
,
async_add_entities
,
discovery_info
=
None
):
...
...
@@ -95,11 +95,11 @@ class HomematicipLightMeasuring(HomematicipLight):
"""
Return the state attributes of the generic device.
"""
state_attr
=
super
().
device_state_attributes
current_power_
consumption
=
self
.
_device
.
currentPowerConsumption
if
current_power_
consumption
>
0.05
:
state_attr
[
ATTR_
POWER_CONSUMPTION
]
=
round
(
current_power_
consumption
,
2
)
current_power_
w
=
self
.
_device
.
currentPowerConsumption
if
current_power_
w
>
0.05
:
state_attr
[
ATTR_
CURRENT_POWER_W
]
=
round
(
current_power_
w
,
2
)
state_attr
[
ATTR_ENERGY_
COUNTER
]
=
round
(
self
.
_device
.
energyCounter
,
2
)
state_attr
[
ATTR_
TODAY_
ENERGY_
KWH
]
=
round
(
self
.
_device
.
energyCounter
,
2
)
return
state_attr
...
...
This diff is collapsed.
Click to expand it.
tests/components/homematicip_cloud/test_light.py
+
4
−
4
View file @
b7296c61
...
...
@@ -3,8 +3,8 @@ from homematicip.base.enums import RGBColorState
from
homeassistant.components.homematicip_cloud
import
DOMAIN
as
HMIPC_DOMAIN
from
homeassistant.components.homematicip_cloud.light
import
(
ATTR_
ENERGY_COUNTER
,
ATTR_
POWER_CONSUMPTION
,
ATTR_
CURRENT_POWER_W
,
ATTR_
TODAY_ENERGY_KWH
,
)
from
homeassistant.components.light
import
(
ATTR_BRIGHTNESS
,
...
...
@@ -209,8 +209,8 @@ async def test_hmip_light_measuring(hass, default_mock_hap):
await
async_manipulate_test_data
(
hass
,
hmip_device
,
"
currentPowerConsumption
"
,
50
)
ha_state
=
hass
.
states
.
get
(
entity_id
)
assert
ha_state
.
state
==
STATE_ON
assert
ha_state
.
attributes
[
ATTR_
POWER_CONSUMPTION
]
==
50
assert
ha_state
.
attributes
[
ATTR_ENERGY_
COUNTER
]
==
6.33
assert
ha_state
.
attributes
[
ATTR_
CURRENT_POWER_W
]
==
50
assert
ha_state
.
attributes
[
ATTR_
TODAY_
ENERGY_
KWH
]
==
6.33
await
hass
.
services
.
async_call
(
"
light
"
,
"
turn_off
"
,
{
"
entity_id
"
:
entity_id
},
blocking
=
True
...
...
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