Skip to content

Commit

Permalink
fix construct enums for hass
Browse files Browse the repository at this point in the history
  • Loading branch information
jblance authored Jan 15, 2025
1 parent 823d1f1 commit c7d4970
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions powermon/outputformats/hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json as js
import logging
from datetime import datetime
import construct as cs
from enum import Enum

from powermon.commands.command import Command
from powermon.commands.reading import Reading
Expand Down Expand Up @@ -132,6 +134,9 @@ def format(self, command: Command, result: Result, device_info) -> list:
config_msgs.append(msg)

# VALUE SETTING
# convert construct EnumIntegerStrings to a str
if isinstance(value, cs.EnumIntegerString):
value = str(value)
msg = {"topic": state_topic, "payload": value}
value_msgs.append(msg)

Expand Down
5 changes: 3 additions & 2 deletions tests/config/ble_neey.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ commands:
outputs:
- type: screen
format:
type: table
draw_lines: True
type: hass
# draw_lines: True
filter: buzzer

mqttbroker:
name: localhost
Expand Down

0 comments on commit c7d4970

Please sign in to comment.