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
b28f3529
Unverified
Commit
b28f3529
authored
4 months ago
by
Robert Resch
Committed by
GitHub
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove deprecated binary sensor constants (#131793)
parent
fb152c7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/binary_sensor/__init__.py
+0
-102
0 additions, 102 deletions
homeassistant/components/binary_sensor/__init__.py
tests/components/binary_sensor/test_init.py
+0
-21
0 additions, 21 deletions
tests/components/binary_sensor/test_init.py
with
0 additions
and
123 deletions
homeassistant/components/binary_sensor/__init__.py
+
0
−
102
View file @
b28f3529
...
...
@@ -4,7 +4,6 @@ from __future__ import annotations
from
datetime
import
timedelta
from
enum
import
StrEnum
from
functools
import
partial
import
logging
from
typing
import
Literal
,
final
...
...
@@ -16,12 +15,6 @@ from homeassistant.const import STATE_OFF, STATE_ON, EntityCategory
from
homeassistant.core
import
HomeAssistant
from
homeassistant.exceptions
import
HomeAssistantError
from
homeassistant.helpers
import
config_validation
as
cv
from
homeassistant.helpers.deprecation
import
(
DeprecatedConstantEnum
,
all_with_deprecated_constants
,
check_if_deprecated_constant
,
dir_with_deprecated_constants
,
)
from
homeassistant.helpers.entity
import
Entity
,
EntityDescription
from
homeassistant.helpers.entity_component
import
EntityComponent
from
homeassistant.helpers.typing
import
ConfigType
...
...
@@ -126,94 +119,7 @@ class BinarySensorDeviceClass(StrEnum):
DEVICE_CLASSES_SCHEMA
=
vol
.
All
(
vol
.
Lower
,
vol
.
Coerce
(
BinarySensorDeviceClass
))
# DEVICE_CLASS* below are deprecated as of 2021.12
# use the BinarySensorDeviceClass enum instead.
DEVICE_CLASSES
=
[
cls
.
value
for
cls
in
BinarySensorDeviceClass
]
_DEPRECATED_DEVICE_CLASS_BATTERY
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
BATTERY
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_BATTERY_CHARGING
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
BATTERY_CHARGING
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_CO
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
CO
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_COLD
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
COLD
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_CONNECTIVITY
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
CONNECTIVITY
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_DOOR
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
DOOR
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_GARAGE_DOOR
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
GARAGE_DOOR
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_GAS
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
GAS
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_HEAT
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
HEAT
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_LIGHT
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
LIGHT
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_LOCK
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
LOCK
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_MOISTURE
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
MOISTURE
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_MOTION
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
MOTION
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_MOVING
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
MOVING
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_OCCUPANCY
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
OCCUPANCY
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_OPENING
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
OPENING
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_PLUG
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
PLUG
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_POWER
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
POWER
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_PRESENCE
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
PRESENCE
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_PROBLEM
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
PROBLEM
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_RUNNING
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
RUNNING
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_SAFETY
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
SAFETY
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_SMOKE
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
SMOKE
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_SOUND
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
SOUND
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_TAMPER
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
TAMPER
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_UPDATE
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
UPDATE
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_VIBRATION
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
VIBRATION
,
"
2025.1
"
)
_DEPRECATED_DEVICE_CLASS_WINDOW
=
DeprecatedConstantEnum
(
BinarySensorDeviceClass
.
WINDOW
,
"
2025.1
"
)
# mypy: disallow-any-generics
...
...
@@ -294,11 +200,3 @@ class BinarySensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_)
if
(
is_on
:
=
self
.
is_on
)
is
None
:
return
None
return
STATE_ON
if
is_on
else
STATE_OFF
# These can be removed if no deprecated constant are in this module anymore
__getattr__
=
partial
(
check_if_deprecated_constant
,
module_globals
=
globals
())
__dir__
=
partial
(
dir_with_deprecated_constants
,
module_globals_keys
=
[
*
globals
().
keys
()]
)
__all__
=
all_with_deprecated_constants
(
globals
())
This diff is collapsed.
Click to expand it.
tests/components/binary_sensor/test_init.py
+
0
−
21
View file @
b28f3529
...
...
@@ -17,8 +17,6 @@ from tests.common import (
MockConfigEntry
,
MockModule
,
MockPlatform
,
help_test_all
,
import_and_test_deprecated_constant_enum
,
mock_config_flow
,
mock_integration
,
mock_platform
,
...
...
@@ -198,22 +196,3 @@ async def test_entity_category_config_raises_error(
"
Entity binary_sensor.test2 cannot be added as the entity category is set to config
"
in
caplog
.
text
)
def
test_all
()
->
None
:
"""
Test module.__all__ is correctly set.
"""
help_test_all
(
binary_sensor
)
@pytest.mark.parametrize
(
"
device_class
"
,
list
(
binary_sensor
.
BinarySensorDeviceClass
),
)
def
test_deprecated_constant_device_class
(
caplog
:
pytest
.
LogCaptureFixture
,
device_class
:
binary_sensor
.
BinarySensorDeviceClass
,
)
->
None
:
"""
Test deprecated binary sensor device classes.
"""
import_and_test_deprecated_constant_enum
(
caplog
,
binary_sensor
,
device_class
,
"
DEVICE_CLASS_
"
,
"
2025.1
"
)
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