Skip to content

Commit

Permalink
fix: Add documentation + check of expire function
Browse files Browse the repository at this point in the history
  • Loading branch information
egguy committed Mar 10, 2024
1 parent be2399b commit ffd13ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/grottext/ha/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
MQTT_PASSWORD_CONF_KEY = "ha_mqtt_password"
MQTT_RETAIN_CONF_KEY = "ha_mqtt_retain"

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


Expand All @@ -19,6 +20,3 @@ class MQTTConfiguration:
hostname: str
port: int
client_id: str = "Grott - HA"


MQTT_EXPIRE_AFTER = 15 * 60 # 15 minutes
2 changes: 2 additions & 0 deletions tests/test_mappings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from grottext.ha.constants import MQTT_EXPIRE_AFTER
from grottext.ha.ha_types import to_dict
from grottext.ha.mappings import mapping
from grottext.ha.mqtt import MQTTConfigPayload, make_payload
Expand All @@ -18,6 +19,7 @@ def test_generate_payload(fake_config):
assert payload["state_class"] == "measurement"
assert payload["device_class"] == "power"
assert payload["unit_of_measurement"] == "W"
assert payload["expire_after"] == MQTT_EXPIRE_AFTER


def test_generate_log_type_payload(fake_config):
Expand Down

0 comments on commit ffd13ff

Please sign in to comment.