mirror of
https://github.com/vakius/hassio-addon-lifepo4wered.git
synced 2026-08-01 20:44:12 +03:00
Compare commits
2 Commits
3d8deb1176
...
93c1f8d3bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93c1f8d3bc | ||
|
|
c1c96d3cfb |
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "LiFePO4wered Addon",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.3",
|
||||
"init": false,
|
||||
"slug": "lifepo4wered",
|
||||
"description": "Add-on with service and MQTT monitor for LiFePO4wered/Pi+ UPS",
|
||||
|
||||
@@ -83,23 +83,25 @@ DIAG_VOLTAGE = [
|
||||
("VBAT_MIN", "Battery minimum voltage"),
|
||||
("VBAT_SHDN", "Battery shutdown voltage"),
|
||||
("VBAT_BOOT", "Battery boot voltage"),
|
||||
("VOUT_MAX", "Output maximum voltage"),
|
||||
("VIN_THRESHOLD", "Input power threshold"),
|
||||
("VOUT_MAX", "Max output voltage to allow boot"),
|
||||
("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 = [
|
||||
("AUTO_BOOT", "Auto boot mode"),
|
||||
("SHDN_DELAY", "Shutdown delay"),
|
||||
("AUTO_SHDN_TIME", "Auto shutdown time"),
|
||||
("PI_BOOT_TO", "Pi boot timeout"),
|
||||
("PI_SHDN_TO", "Pi shutdown timeout"),
|
||||
("WATCHDOG_CFG", "Watchdog mode"),
|
||||
("WATCHDOG_GRACE", "Watchdog grace"),
|
||||
("WATCHDOG_TIMER", "Watchdog timer"),
|
||||
("PI_RUNNING", "Pi running flag"),
|
||||
("LED_STATE", "LED state"),
|
||||
("TOUCH_STATE", "Touch state"),
|
||||
("AUTO_BOOT", "Auto boot mode", None),
|
||||
("SHDN_DELAY", "Shutdown delay", None),
|
||||
("AUTO_SHDN_TIME", "Auto shutdown time", "min"),
|
||||
("PI_BOOT_TO", "Pi boot timeout", "s"),
|
||||
("PI_SHDN_TO", "Pi shutdown timeout", "s"),
|
||||
("WATCHDOG_CFG", "Watchdog mode", None),
|
||||
("WATCHDOG_GRACE", "Watchdog grace period", "s"),
|
||||
("WATCHDOG_TIMER", "Watchdog timer", "s"),
|
||||
("PI_RUNNING", "Pi running", None),
|
||||
("LED_STATE", "LED state", None),
|
||||
("TOUCH_STATE", "Touch button state", None),
|
||||
]
|
||||
|
||||
|
||||
@@ -184,11 +186,13 @@ def discovery_messages(discovery_prefix, state_topic, availability_topic):
|
||||
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(
|
||||
"sensor", key, name,
|
||||
entity_category="diagnostic",
|
||||
value_template="{{ value_json.%s }}" % key,
|
||||
**extra,
|
||||
)
|
||||
|
||||
yield entity(
|
||||
|
||||
Binary file not shown.
@@ -62,6 +62,17 @@ class DiscoveryTest(unittest.TestCase):
|
||||
self.assertEqual(cfg["entity_category"], "diagnostic")
|
||||
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):
|
||||
for key in ("i2c_reg_ver", "dco_rsel", "vbat_offset", "cfg_write"):
|
||||
self.assertNotIn(
|
||||
|
||||
Reference in New Issue
Block a user