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
b5bb97c8
Unverified
Commit
b5bb97c8
authored
1 year ago
by
Florian Kisser
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix zha illuminance measured value mapping (#108547)
parent
3c6e7b18
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/zha/sensor.py
+5
-1
5 additions, 1 deletion
homeassistant/components/zha/sensor.py
tests/components/zha/test_sensor.py
+6
-0
6 additions, 0 deletions
tests/components/zha/test_sensor.py
with
11 additions
and
1 deletion
homeassistant/components/zha/sensor.py
+
5
−
1
View file @
b5bb97c8
...
@@ -483,8 +483,12 @@ class Illuminance(Sensor):
...
@@ -483,8 +483,12 @@ class Illuminance(Sensor):
_attr_state_class
:
SensorStateClass
=
SensorStateClass
.
MEASUREMENT
_attr_state_class
:
SensorStateClass
=
SensorStateClass
.
MEASUREMENT
_attr_native_unit_of_measurement
=
LIGHT_LUX
_attr_native_unit_of_measurement
=
LIGHT_LUX
def
formatter
(
self
,
value
:
int
)
->
int
:
def
formatter
(
self
,
value
:
int
)
->
int
|
None
:
"""
Convert illumination data.
"""
"""
Convert illumination data.
"""
if
value
==
0
:
return
0
if
value
==
0xFFFF
:
return
None
return
round
(
pow
(
10
,
((
value
-
1
)
/
10000
)))
return
round
(
pow
(
10
,
((
value
-
1
)
/
10000
)))
...
...
This diff is collapsed.
Click to expand it.
tests/components/zha/test_sensor.py
+
6
−
0
View file @
b5bb97c8
...
@@ -136,6 +136,12 @@ async def async_test_illuminance(hass, cluster, entity_id):
...
@@ -136,6 +136,12 @@ async def async_test_illuminance(hass, cluster, entity_id):
await
send_attributes_report
(
hass
,
cluster
,
{
1
:
1
,
0
:
10
,
2
:
20
})
await
send_attributes_report
(
hass
,
cluster
,
{
1
:
1
,
0
:
10
,
2
:
20
})
assert_state
(
hass
,
entity_id
,
"
1
"
,
LIGHT_LUX
)
assert_state
(
hass
,
entity_id
,
"
1
"
,
LIGHT_LUX
)
await
send_attributes_report
(
hass
,
cluster
,
{
1
:
0
,
0
:
0
,
2
:
20
})
assert_state
(
hass
,
entity_id
,
"
0
"
,
LIGHT_LUX
)
await
send_attributes_report
(
hass
,
cluster
,
{
1
:
0
,
0
:
0xFFFF
,
2
:
20
})
assert_state
(
hass
,
entity_id
,
"
unknown
"
,
LIGHT_LUX
)
async
def
async_test_metering
(
hass
,
cluster
,
entity_id
):
async
def
async_test_metering
(
hass
,
cluster
,
entity_id
):
"""
Test Smart Energy metering sensor.
"""
"""
Test Smart Energy metering sensor.
"""
...
...
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