Skip to content

Commit

Permalink
always include min/max ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Jan 20, 2021
1 parent 3d3201e commit b4eabc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 5 additions & 3 deletions custom_components/sensorpush/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from homeassistant.const import CONF_NAME, CONF_USERNAME, CONF_PASSWORD, CONF_SCAN_INTERVAL

from .const import (ATTR_BATTERY_VOLTAGE, ATTR_DEVICE_ID, ATTR_OBSERVED_TIME, ATTR_AGE,
ATTR_ATTRIBUTION, ATTRIBUTION,
ATTR_ATTRIBUTION, ATTRIBUTION, MEASURES,
ATTR_ALERT_MIN, ATTR_ALERT_MAX, CONF_UNIT_SYSTEM, CONF_MAXIMUM_AGE,
SENSORPUSH_DOMAIN, UNIT_SYSTEM_IMPERIAL, UNIT_SYSTEM_METRIC, UNIT_SYSTEMS)

Expand Down Expand Up @@ -129,7 +129,7 @@ def name(self):

@property
def icon(self):
return 'mdi:gauge'
return MEASURES[self._field_name].get('icon') or 'mdi:gauge'

@property
def state(self):
Expand Down Expand Up @@ -169,12 +169,14 @@ def _update_callback(self):
})

alerts = self._sensor_info.get("alerts").get(self._field_name)
if alerts.get("enabled") == "True":
if alerts.get("min"):
self._attrs.update({
ATTR_ALERT_MIN: alerts.get("min"),
ATTR_ALERT_MAX: alerts.get("max")
})

# LOG.info(f"{self._state} ... {self._attrs} ... {sensor_data} ... {self._sensor_info}")

# let Home Assistant know that SensorPush data for this entity has been updated
self.async_schedule_update_ha_state()

Expand Down
4 changes: 0 additions & 4 deletions custom_components/sensorpush/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def __init__(self, hass, config, sensor_info, unit_system, measure):
self._state = None
super().__init__(hass, config, self._name, sensor_info, unit_system, measure)

@property
def icon(self):
return MEASURES[self._field_name]['icon']

@property
def unit_of_measurement(self):
return UNIT_SYSTEMS[self._unit_system][self._field_name]
Expand Down

0 comments on commit b4eabc6

Please sign in to comment.