Skip to content

Commit

Permalink
Merge pull request #2 from trizmark/expose-libbi-energy-data
Browse files Browse the repository at this point in the history
Expose libbi energy data
  • Loading branch information
trizmark authored Sep 22, 2023
2 parents 1360083 + 6b94b98 commit f7275d2
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/myenergi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NAME = "myenergi"
DOMAIN = "myenergi"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.23"
VERSION = "0.0.24"

ATTRIBUTION = "Data provided by myenergi"
ISSUE_URL = "https://github.com/CJNE/ha-myenergi/issues"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/myenergi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"documentation": "https://github.com/cjne/ha-myenergi",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/cjne/ha-myenergi/issues",
"requirements": ["pymyenergi==0.0.28"],
"requirements": ["pymyenergi==0.0.29"],
"version": "0.0.24"
}
83 changes: 75 additions & 8 deletions custom_components/myenergi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ async def async_setup_entry(hass, entry, async_add_devices):
"state_of_charge",
DEVICE_CLASS_BATTERY,
PERCENTAGE,
ENTITY_CATEGORY_DIAGNOSTIC,
),
)
)
Expand Down Expand Up @@ -567,15 +566,18 @@ async def async_setup_entry(hass, entry, async_add_devices):
)
)
)
""" expose this temporarily (it's mapped to operating mode)"""
sensors.append(
MyenergiSensor(
coordinator,
device,
entry,
create_meta(
f"Local mode",
"local_mode",
f"Status",
"status",
None,
None,
None,
ICON_HOME_BATTERY,
)
)
)
Expand All @@ -585,12 +587,77 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Status",
"status",
f"Grid import today",
"grid_import",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
)
)
sensors.append(
MyenergiSensor(
coordinator,
device,
entry,
create_meta(
f"Grid export today",
"grid_export",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
ICON_HOME_BATTERY,
None,
STATE_CLASS_TOTAL_INCREASING,
)
)
)
sensors.append(
MyenergiSensor(
coordinator,
device,
entry,
create_meta(
f"Battery charge today",
"battery_charge",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
)
)
sensors.append(
MyenergiSensor(
coordinator,
device,
entry,
create_meta(
f"Battery discharge today",
"battery_discharge",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
)
)
sensors.append(
MyenergiSensor(
coordinator,
device,
entry,
create_meta(
f"Solar generation today",
"generated",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
)
)
Expand All @@ -606,7 +673,7 @@ def __init__(self, coordinator, config_entry, meta):
@property
def unique_id(self):
"""Return a unique ID to use for this entity."""
return f"{self.config_entry.entry_id}-{self.coordinator.client.serial_number}-{self.meta['prop_name']}"
return f"{self.config_entry.entry_id}-hub-{self.coordinator.client.serial_number}-{self.meta['prop_name']}"

@property
def name(self):
Expand Down

0 comments on commit f7275d2

Please sign in to comment.