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
9467b7d0
Unverified
Commit
9467b7d0
authored
2 years ago
by
epenet
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve type hint in eq3btsmart climate entity (#77131)
parent
5a0e4fa5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/eq3btsmart/climate.py
+12
-43
12 additions, 43 deletions
homeassistant/components/eq3btsmart/climate.py
with
12 additions
and
43 deletions
homeassistant/components/eq3btsmart/climate.py
+
12
−
43
View file @
9467b7d0
...
@@ -100,37 +100,26 @@ def setup_platform(
...
@@ -100,37 +100,26 @@ def setup_platform(
class
EQ3BTSmartThermostat
(
ClimateEntity
):
class
EQ3BTSmartThermostat
(
ClimateEntity
):
"""
Representation of an eQ-3 Bluetooth Smart thermostat.
"""
"""
Representation of an eQ-3 Bluetooth Smart thermostat.
"""
_attr_hvac_modes
=
list
(
HA_TO_EQ_HVAC
)
_attr_precision
=
PRECISION_HALVES
_attr_preset_modes
=
list
(
HA_TO_EQ_PRESET
)
_attr_supported_features
=
(
_attr_supported_features
=
(
ClimateEntityFeature
.
TARGET_TEMPERATURE
|
ClimateEntityFeature
.
PRESET_MODE
ClimateEntityFeature
.
TARGET_TEMPERATURE
|
ClimateEntityFeature
.
PRESET_MODE
)
)
_attr_temperature_unit
=
TEMP_CELSIUS
def
__init__
(
self
,
_
mac
,
_
name
)
:
def
__init__
(
self
,
mac
:
str
,
name
:
str
)
->
None
:
"""
Initialize the thermostat.
"""
"""
Initialize the thermostat.
"""
# We want to avoid name clash with this module.
# We want to avoid name clash with this module.
self
.
_name
=
_
name
self
.
_
attr_
name
=
name
self
.
_
mac
=
_mac
self
.
_
attr_unique_id
=
format_mac
(
mac
)
self
.
_thermostat
=
eq3
.
Thermostat
(
_
mac
)
self
.
_thermostat
=
eq3
.
Thermostat
(
mac
)
@property
@property
def
available
(
self
)
->
bool
:
def
available
(
self
)
->
bool
:
"""
Return if thermostat is available.
"""
"""
Return if thermostat is available.
"""
return
self
.
_thermostat
.
mode
>=
0
return
self
.
_thermostat
.
mode
>=
0
@property
def
name
(
self
):
"""
Return the name of the device.
"""
return
self
.
_name
@property
def
temperature_unit
(
self
):
"""
Return the unit of measurement that is used.
"""
return
TEMP_CELSIUS
@property
def
precision
(
self
):
"""
Return eq3bt
'
s precision 0.5.
"""
return
PRECISION_HALVES
@property
@property
def
current_temperature
(
self
):
def
current_temperature
(
self
):
"""
Can not report temperature, so return target_temperature.
"""
"""
Can not report temperature, so return target_temperature.
"""
...
@@ -148,17 +137,12 @@ class EQ3BTSmartThermostat(ClimateEntity):
...
@@ -148,17 +137,12 @@ class EQ3BTSmartThermostat(ClimateEntity):
self
.
_thermostat
.
target_temperature
=
temperature
self
.
_thermostat
.
target_temperature
=
temperature
@property
@property
def
hvac_mode
(
self
):
def
hvac_mode
(
self
)
->
HVACMode
:
"""
Return the current operation mode.
"""
"""
Return the current operation mode.
"""
if
self
.
_thermostat
.
mode
<
0
:
if
self
.
_thermostat
.
mode
<
0
:
return
HVACMode
.
OFF
return
HVACMode
.
OFF
return
EQ_TO_HA_HVAC
[
self
.
_thermostat
.
mode
]
return
EQ_TO_HA_HVAC
[
self
.
_thermostat
.
mode
]
@property
def
hvac_modes
(
self
):
"""
Return the list of available operation modes.
"""
return
list
(
HA_TO_EQ_HVAC
)
def
set_hvac_mode
(
self
,
hvac_mode
:
HVACMode
)
->
None
:
def
set_hvac_mode
(
self
,
hvac_mode
:
HVACMode
)
->
None
:
"""
Set operation mode.
"""
"""
Set operation mode.
"""
self
.
_thermostat
.
mode
=
HA_TO_EQ_HVAC
[
hvac_mode
]
self
.
_thermostat
.
mode
=
HA_TO_EQ_HVAC
[
hvac_mode
]
...
@@ -174,9 +158,9 @@ class EQ3BTSmartThermostat(ClimateEntity):
...
@@ -174,9 +158,9 @@ class EQ3BTSmartThermostat(ClimateEntity):
return
self
.
_thermostat
.
max_temp
return
self
.
_thermostat
.
max_temp
@property
@property
def
extra_state_attributes
(
self
):
def
extra_state_attributes
(
self
)
->
dict
[
str
,
Any
]
:
"""
Return the device specific state attributes.
"""
"""
Return the device specific state attributes.
"""
dev_specific
=
{
return
{
ATTR_STATE_AWAY_END
:
self
.
_thermostat
.
away_end
,
ATTR_STATE_AWAY_END
:
self
.
_thermostat
.
away_end
,
ATTR_STATE_LOCKED
:
self
.
_thermostat
.
locked
,
ATTR_STATE_LOCKED
:
self
.
_thermostat
.
locked
,
ATTR_STATE_LOW_BAT
:
self
.
_thermostat
.
low_battery
,
ATTR_STATE_LOW_BAT
:
self
.
_thermostat
.
low_battery
,
...
@@ -184,29 +168,14 @@ class EQ3BTSmartThermostat(ClimateEntity):
...
@@ -184,29 +168,14 @@ class EQ3BTSmartThermostat(ClimateEntity):
ATTR_STATE_WINDOW_OPEN
:
self
.
_thermostat
.
window_open
,
ATTR_STATE_WINDOW_OPEN
:
self
.
_thermostat
.
window_open
,
}
}
return
dev_specific
@property
@property
def
preset_mode
(
self
):
def
preset_mode
(
self
)
->
str
|
None
:
"""
Return the current preset mode, e.g., home, away, temp.
"""
Return the current preset mode, e.g., home, away, temp.
Requires ClimateEntityFeature.PRESET_MODE.
Requires ClimateEntityFeature.PRESET_MODE.
"""
"""
return
EQ_TO_HA_PRESET
.
get
(
self
.
_thermostat
.
mode
)
return
EQ_TO_HA_PRESET
.
get
(
self
.
_thermostat
.
mode
)
@property
def
preset_modes
(
self
):
"""
Return a list of available preset modes.
Requires ClimateEntityFeature.PRESET_MODE.
"""
return
list
(
HA_TO_EQ_PRESET
)
@property
def
unique_id
(
self
)
->
str
:
"""
Return the MAC address of the thermostat.
"""
return
format_mac
(
self
.
_mac
)
def
set_preset_mode
(
self
,
preset_mode
:
str
)
->
None
:
def
set_preset_mode
(
self
,
preset_mode
:
str
)
->
None
:
"""
Set new preset mode.
"""
"""
Set new preset mode.
"""
if
preset_mode
==
PRESET_NONE
:
if
preset_mode
==
PRESET_NONE
:
...
...
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