Skip to content

Commit ffd13ff

Browse files
committed
fix: Add documentation + check of expire function
1 parent be2399b commit ffd13ff

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/grottext/ha/constants.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
MQTT_PASSWORD_CONF_KEY = "ha_mqtt_password"
1111
MQTT_RETAIN_CONF_KEY = "ha_mqtt_retain"
1212

13+
# https://www.home-assistant.io/integrations/sensor.mqtt/#expire_after
1314
MQTT_EXPIRE_AFTER = 15 * 60 # 15 minutes
1415

1516

@@ -19,6 +20,3 @@ class MQTTConfiguration:
1920
hostname: str
2021
port: int
2122
client_id: str = "Grott - HA"
22-
23-
24-
MQTT_EXPIRE_AFTER = 15 * 60 # 15 minutes

tests/test_mappings.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from grottext.ha.constants import MQTT_EXPIRE_AFTER
12
from grottext.ha.ha_types import to_dict
23
from grottext.ha.mappings import mapping
34
from grottext.ha.mqtt import MQTTConfigPayload, make_payload
@@ -18,6 +19,7 @@ def test_generate_payload(fake_config):
1819
assert payload["state_class"] == "measurement"
1920
assert payload["device_class"] == "power"
2021
assert payload["unit_of_measurement"] == "W"
22+
assert payload["expire_after"] == MQTT_EXPIRE_AFTER
2123

2224

2325
def test_generate_log_type_payload(fake_config):

0 commit comments

Comments
 (0)