Fix set up issue AGAIN

This commit is contained in:
2025-08-17 23:02:10 +10:00
parent 0621606782
commit a7259bca08
7 changed files with 270 additions and 87 deletions

View File

@@ -114,7 +114,8 @@ class MedMateDoseDueSensor(MedMateBaseBinarySensor):
next_dose = datetime.fromisoformat(next_dose)
except ValueError:
next_dose = None
attrs["next_dose"] = next_dose
if next_dose:
attrs["next_dose"] = next_dose
return attrs
@@ -146,10 +147,18 @@ class MedMatePrescriptionActiveSensor(MedMateBaseBinarySensor):
data = self.coordinator.data
prescription = data.get(CONF_PRESCRIPTION, {})
return {
"expiry_date": prescription.get(CONF_EXPIRY_DATE),
"repeats_left": prescription.get(CONF_REPEATS_LEFT, 0),
}
# Only return expected keys
attrs = {}
expiry_date = prescription.get(CONF_EXPIRY_DATE)
if expiry_date:
attrs["expiry_date"] = expiry_date
repeats_left = prescription.get(CONF_REPEATS_LEFT)
if repeats_left is not None:
attrs["repeats_left"] = repeats_left
return attrs
class MedMateLowInventorySensor(MedMateBaseBinarySensor):
@@ -176,7 +185,6 @@ class MedMateLowInventorySensor(MedMateBaseBinarySensor):
inventory = data.get("inventory", 0)
# Consider inventory low if less than 7 doses remain
# This assumes daily medication - could be made configurable
return inventory < 7
@property