Skip to content

Commit 99a9df4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 8e85292 commit 99a9df4

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

ha_mqtt_discoverable/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,10 @@ class ClimateSubscriber(Discoverable[EntityType]):
908908
T = TypeVar("T") # Used in the callback function
909909

910910
def __init__(
911-
self,
912-
settings: Settings[EntityType],
913-
command_callback: Callable[[mqtt.Client, T, mqtt.MQTTMessage], Any],
914-
user_data: T = None,
911+
self,
912+
settings: Settings[EntityType],
913+
command_callback: Callable[[mqtt.Client, T, mqtt.MQTTMessage], Any],
914+
user_data: T = None,
915915
) -> None:
916916
"""
917917
Entity that listens to commands from an MQTT topic.
@@ -955,15 +955,19 @@ def generate_config(self) -> dict[str, Any]:
955955
# Add the MQTT command topic to the existing config object
956956
topics = {
957957
"mode_command_topic": self._mode_command_topic,
958-
"mode_command_template": json.dumps({
959-
"command": "mode",
960-
"value": "{{ value }}",
961-
}),
958+
"mode_command_template": json.dumps(
959+
{
960+
"command": "mode",
961+
"value": "{{ value }}",
962+
}
963+
),
962964
"temperature_command_topic": self._temperature_command_topic,
963-
"temperature_command_template": json.dumps({
964-
"command": "temperature",
965-
"value": "{{ value }}",
966-
}),
965+
"temperature_command_template": json.dumps(
966+
{
967+
"command": "temperature",
968+
"value": "{{ value }}",
969+
}
970+
),
967971
"mode_state_topic": self._mode_state_topic,
968972
"current_temperature_topic": self._current_temperature_topic,
969973
"temperature_state_topic": self._temperature_state_topic,

ha_mqtt_discoverable/sensors.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
from pydantic import Field, model_validator
2424

2525
from ha_mqtt_discoverable import (
26+
ClimateSubscriber,
2627
DeviceInfo,
2728
Discoverable,
2829
EntityInfo,
2930
Subscriber,
30-
ClimateSubscriber,
3131
)
3232

3333
logger = logging.getLogger(__name__)
@@ -392,17 +392,15 @@ def set_current_temperature(self, temperature: float) -> None:
392392
"""Set target temperature"""
393393
if temperature < self._entity.min_temp or temperature > self._entity.max_temp:
394394
raise RuntimeError(
395-
f"Temperature {temperature} is outside valid range "
396-
f"[{self._entity.min_temp}, {self._entity.max_temp}]"
395+
f"Temperature {temperature} is outside valid range [{self._entity.min_temp}, {self._entity.max_temp}]"
397396
)
398397
self._state_helper(temperature, self._current_temperature_topic)
399398

400399
def set_target_temperature(self, temperature: float) -> None:
401400
"""Set target temperature"""
402401
if temperature < self._entity.min_temp or temperature > self._entity.max_temp:
403402
raise RuntimeError(
404-
f"Temperature {temperature} is outside valid range "
405-
f"[{self._entity.min_temp}, {self._entity.max_temp}]"
403+
f"Temperature {temperature} is outside valid range [{self._entity.min_temp}, {self._entity.max_temp}]"
406404
)
407405
self._state_helper(temperature, self._temperature_state_topic)
408406

tests/test_climate.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66
# Test data
77
modes = ["off", "heat"]
88

9+
910
@pytest.fixture
1011
def climate() -> Climate:
1112
"""Test climate temperature settings"""
1213
mqtt_settings = Settings.MQTT(host="localhost")
13-
climate_info = ClimateInfo(
14-
name="test_climate",
15-
temperature_unit="C",
16-
min_temp=16,
17-
max_temp=32,
18-
modes=modes
19-
)
14+
climate_info = ClimateInfo(name="test_climate", temperature_unit="C", min_temp=16, max_temp=32, modes=modes)
2015
settings = Settings(mqtt=mqtt_settings, entity=climate_info)
2116
return Climate(settings, lambda *_: None)
2217

@@ -36,6 +31,7 @@ def test_set_temperature(climate: Climate):
3631
with pytest.raises(RuntimeError):
3732
climate.set_target_temperature(33.0) # Above max_temp
3833

34+
3935
def test_climate_mode(climate: Climate):
4036
"""Test climate mode settings"""
4137
# Valid mode

0 commit comments

Comments
 (0)