Skip to content

Commit

Permalink
Fixed enum value bug, version 0.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed May 8, 2023
1 parent f0e2b1c commit a40293a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/sunspec/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NAME = "SunSpec"
DOMAIN = "sunspec"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.23"
VERSION = "0.0.24"

ATTRIBUTION = "Data provided by SunSpec alliance - https://sunspec.org"
ISSUE_URL = "https://github.com/cjne/ha-sunspec/issues"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sunspec/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/cjne/ha-sunspec/issues",
"requirements": ["pysunspec2==1.0.8"],
"version": "0.0.23"
"version": "0.0.24"
}
7 changes: 3 additions & 4 deletions custom_components/sunspec/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ async def async_setup_entry(hass, entry, async_add_devices):
sunspec_unit = meta.get("units", "")
ha_meta = HA_META.get(sunspec_unit, [sunspec_unit, None, None])
device_class = ha_meta[2]
if sunspec_unit == "":
_LOGGER.debug("No unit for")
_LOGGER.debug(meta)
if device_class == DEVICE_CLASS_ENERGY:
_LOGGER.debug("Adding energy sensor")
sensors.append(SunSpecEnergySensor(coordinator, entry, data))
Expand Down Expand Up @@ -176,6 +173,8 @@ def __init__(self, coordinator, config_entry, data):
self.use_device_class,
self.unit,
)
if self.device_class == SensorDeviceClass.ENUM:
_LOGGER.debug("Valid options for ENUM: %s", self._options)

# def async_will_remove_from_hass(self):
# _LOGGER.debug(f"Will remove sensor {self._uniqe_id}")
Expand Down Expand Up @@ -214,7 +213,7 @@ def native_value(self):
return None
vtype = self._meta["type"]
if vtype in ("enum16", "bitfield32"):
symbols = self._meta.get("symbols", None)
symbols = self._point_meta.get("symbols", None)
if symbols is None:
return val
if vtype == "enum16":
Expand Down

0 comments on commit a40293a

Please sign in to comment.