Skip to content

Commit 6a8ddc3

Browse files
authored
Merge pull request #51 from zestysoft/use_CCF_or_gal_for_units-2
Fix config issue and refresh sensors on config change
2 parents b87f8f3 + a399d03 commit 6a8ddc3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

custom_components/sensus_analytics/config_flow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ async def async_step_init(self, user_input=None) -> FlowResult:
100100
_LOGGER.debug("User updated options: %s", user_input)
101101
# Update the entry with new options
102102
self.hass.config_entries.async_update_entry(self.config_entry, data=user_input)
103+
# Force a sensor refresh
104+
coordinator = self.hass.data[DOMAIN][self.config_entry.entry_id]
105+
await coordinator.async_request_refresh()
103106
return self.async_create_entry(title="", data={})
104107

105108
# Fetch current configuration data

custom_components/sensus_analytics/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "sensus_analytics",
33
"name": "Sensus Analytics Integration",
4-
"version": "1.6.8",
4+
"version": "1.6.9",
55
"documentation": "https://github.com/zestysoft/sensus_analytics_integration",
66
"dependencies": [],
77
"codeowners": ["@zestysoft"],

custom_components/sensus_analytics/sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _convert_usage(self, usage, usage_unit=None):
4848
return None
4949
if usage_unit is None:
5050
usage_unit = self.coordinator.data.get("usageUnit")
51-
if usage_unit == "CF" and self.coordinator.config_entry.data.get("unit_type") == "G":
51+
if usage_unit == "CCF" and self.coordinator.config_entry.data.get("unit_type") == "gal":
5252
try:
5353
return round(float(usage) * CF_TO_GALLON)
5454
except (ValueError, TypeError):
@@ -75,8 +75,8 @@ def __init__(self, coordinator, entry):
7575
def _get_usage_unit(self):
7676
"""Determine the unit of measurement for usage sensors."""
7777
usage_unit = self.coordinator.data.get("usageUnit")
78-
if usage_unit == "CF" and self.coordinator.config_entry.data.get("unit_type") == "G":
79-
return "G"
78+
if usage_unit == "CCF" and self.coordinator.config_entry.data.get("unit_type") == "gal":
79+
return "gal"
8080
return usage_unit
8181

8282
@property

0 commit comments

Comments
 (0)