Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
* Fix float coerce in input settings

* Fix recreate statistics service

* New websockets API

* Fix error when entering floats in prices config_flow

* Improve statistics recreation to avoid loss of old data

* Implement new websockets api to directly fetch statistics from HA "long term statistics"

* Fix some styling issues

* Include surplus energy to statistics

* Add lovelace to manifest

* Add edata-card

* Update docs

* Fix entry removal/unload

* Remove old deprecated code and implement device/entity logic

* Restore some outdated code and explode attributes to different sensors

* Code simplification

* Adding new config flow options

* Fix translations

* Update edata backend

* Restoring debug functionality in options config_flow

* Adding migration function for new storage strategy

* Add billing simulation at options config_flow

* Rewrite history on billing options changes

* Fix #214 #210 #215 #198 #199 #223 #231 #233 #235 #207 #204
  • Loading branch information
uvejota authored Aug 12, 2024
1 parent b646c6f commit f3e07f2
Show file tree
Hide file tree
Showing 28 changed files with 3,095 additions and 1,276 deletions.
401 changes: 166 additions & 235 deletions README.md

Large diffs are not rendered by default.

Binary file added assets/card-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/configure-step3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/configure-step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/install-step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sensors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 23 additions & 6 deletions custom_components/edata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
"""e-data integration"""
"""Home Assistant e-data integration."""

from __future__ import annotations

import logging
from pathlib import Path

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType

from . import utils
from .const import DOMAIN

PLATFORMS: list[str] = ["sensor"]
_LOGGER = logging.getLogger(__name__)


async def async_setup(hass: HomeAssistant, config: ConfigType):
"""Set up edata-card resources."""

path = Path(__file__).parent / "www"
name = "edata-card.js"
utils.register_static_path(hass.http.app, "/edata/" + name, path / name)
version = getattr(hass.data["integrations"][DOMAIN], "version", 0)
await utils.init_resource(hass, "/edata/edata-card.js", str(version))
return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up edata from a config entry."""

# Registers update listener to update config entry when options are updated.
unsub_options_update_listener = entry.add_update_listener(options_update_listener)
entry.async_on_unload(unsub_options_update_listener)

hass.async_create_task(
hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""

unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN][entry.data.get("scups").upper()] = {}
hass.data.get(DOMAIN, {}).pop(entry.data.get("scups"), None)

return unload_ok


async def async_remove_entry(hass, entry) -> None:
async def async_remove_entry(hass: HomeAssistant, entry) -> None:
"""Handle removal of an entry."""

hass.data.get(DOMAIN, {}).pop(entry.data.get("scups"), None)


async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry):
"""Handle options update."""

await hass.config_entries.async_reload(config_entry.entry_id)
Loading

0 comments on commit f3e07f2

Please sign in to comment.