mirror of
https://github.com/vakius/hassio-addon-lifepo4wered.git
synced 2026-08-01 20:44:12 +03:00
Fix entity names and add units per the product brief
VOUT_MAX is the safety limit above which the UPS refuses to boot an externally-powered Pi, not an output voltage setting. Also clarify PI_RUNNING, WATCHDOG_GRACE and TOUCH_STATE names, and add documented units: timeouts and watchdog values are CLI-scaled seconds, AUTO_SHDN_TIME is minutes; SHDN_DELAY stays raw ticks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "LiFePO4wered Addon",
|
"name": "LiFePO4wered Addon",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"init": false,
|
"init": false,
|
||||||
"slug": "lifepo4wered",
|
"slug": "lifepo4wered",
|
||||||
"description": "Add-on with service and MQTT monitor for LiFePO4wered/Pi+ UPS",
|
"description": "Add-on with service and MQTT monitor for LiFePO4wered/Pi+ UPS",
|
||||||
|
|||||||
@@ -83,23 +83,25 @@ DIAG_VOLTAGE = [
|
|||||||
("VBAT_MIN", "Battery minimum voltage"),
|
("VBAT_MIN", "Battery minimum voltage"),
|
||||||
("VBAT_SHDN", "Battery shutdown voltage"),
|
("VBAT_SHDN", "Battery shutdown voltage"),
|
||||||
("VBAT_BOOT", "Battery boot voltage"),
|
("VBAT_BOOT", "Battery boot voltage"),
|
||||||
("VOUT_MAX", "Output maximum voltage"),
|
("VOUT_MAX", "Max output voltage to allow boot"),
|
||||||
("VIN_THRESHOLD", "Input voltage threshold"),
|
("VIN_THRESHOLD", "Input voltage threshold"),
|
||||||
]
|
]
|
||||||
|
|
||||||
# raw-value diagnostic registers (units vary or are unitless flags/timers)
|
# raw-value diagnostic registers; units per the product brief (the CLI
|
||||||
|
# scales the timeouts to s and AUTO_SHDN_TIME to min; SHDN_DELAY stays
|
||||||
|
# raw ~8 Hz ticks)
|
||||||
DIAG_RAW = [
|
DIAG_RAW = [
|
||||||
("AUTO_BOOT", "Auto boot mode"),
|
("AUTO_BOOT", "Auto boot mode", None),
|
||||||
("SHDN_DELAY", "Shutdown delay"),
|
("SHDN_DELAY", "Shutdown delay", None),
|
||||||
("AUTO_SHDN_TIME", "Auto shutdown time"),
|
("AUTO_SHDN_TIME", "Auto shutdown time", "min"),
|
||||||
("PI_BOOT_TO", "Pi boot timeout"),
|
("PI_BOOT_TO", "Pi boot timeout", "s"),
|
||||||
("PI_SHDN_TO", "Pi shutdown timeout"),
|
("PI_SHDN_TO", "Pi shutdown timeout", "s"),
|
||||||
("WATCHDOG_CFG", "Watchdog mode"),
|
("WATCHDOG_CFG", "Watchdog mode", None),
|
||||||
("WATCHDOG_GRACE", "Watchdog grace"),
|
("WATCHDOG_GRACE", "Watchdog grace period", "s"),
|
||||||
("WATCHDOG_TIMER", "Watchdog timer"),
|
("WATCHDOG_TIMER", "Watchdog timer", "s"),
|
||||||
("PI_RUNNING", "Pi running flag"),
|
("PI_RUNNING", "Pi running", None),
|
||||||
("LED_STATE", "LED state"),
|
("LED_STATE", "LED state", None),
|
||||||
("TOUCH_STATE", "Touch state"),
|
("TOUCH_STATE", "Touch button state", None),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -184,11 +186,13 @@ def discovery_messages(discovery_prefix, state_topic, availability_topic):
|
|||||||
value_template=millivolts(key),
|
value_template=millivolts(key),
|
||||||
)
|
)
|
||||||
|
|
||||||
for key, name in DIAG_RAW:
|
for key, name, unit in DIAG_RAW:
|
||||||
|
extra = {"unit_of_measurement": unit} if unit else {}
|
||||||
yield entity(
|
yield entity(
|
||||||
"sensor", key, name,
|
"sensor", key, name,
|
||||||
entity_category="diagnostic",
|
entity_category="diagnostic",
|
||||||
value_template="{{ value_json.%s }}" % key,
|
value_template="{{ value_json.%s }}" % key,
|
||||||
|
**extra,
|
||||||
)
|
)
|
||||||
|
|
||||||
yield entity(
|
yield entity(
|
||||||
|
|||||||
Binary file not shown.
@@ -62,6 +62,17 @@ class DiscoveryTest(unittest.TestCase):
|
|||||||
self.assertEqual(cfg["entity_category"], "diagnostic")
|
self.assertEqual(cfg["entity_category"], "diagnostic")
|
||||||
self.assertEqual(cfg["unit_of_measurement"], "V")
|
self.assertEqual(cfg["unit_of_measurement"], "V")
|
||||||
|
|
||||||
|
def test_timer_registers_have_documented_units(self):
|
||||||
|
for key, unit in (("pi_boot_to", "s"), ("pi_shdn_to", "s"),
|
||||||
|
("watchdog_grace", "s"), ("watchdog_timer", "s"),
|
||||||
|
("auto_shdn_time", "min")):
|
||||||
|
cfg = self.messages[
|
||||||
|
"homeassistant/sensor/lifepo4wered/%s/config" % key]
|
||||||
|
self.assertEqual(cfg["unit_of_measurement"], unit, key)
|
||||||
|
self.assertNotIn(
|
||||||
|
"unit_of_measurement",
|
||||||
|
self.messages["homeassistant/sensor/lifepo4wered/shdn_delay/config"])
|
||||||
|
|
||||||
def test_skipped_registers_have_no_entity(self):
|
def test_skipped_registers_have_no_entity(self):
|
||||||
for key in ("i2c_reg_ver", "dco_rsel", "vbat_offset", "cfg_write"):
|
for key in ("i2c_reg_ver", "dco_rsel", "vbat_offset", "cfg_write"):
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
|
|||||||
Reference in New Issue
Block a user