-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved "options" to basic configuration - `scan_interval` and `debug_mode`can now be set under the (...) menu using the "Reconfigure" option - Made configuration editable by providing `async_setup_reconfigure` function (see above) - Added serial number to device in integration overview - Disabled `OptionsFlowHandler` class since there are no more options ;) - Disabled some functions that were never called - Reworked config reload to be compatible with HA 2025.1 onward - Added/removed translations where appropriate - Removed unused constants - Fixed a bug that caused the sensors to be read every second thereby causing unnecessary load Signed-off-by: stefan <[email protected]>
- Loading branch information
Showing
8 changed files
with
248 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,44 @@ | ||
"""The Sonnenbatterie integration.""" | ||
|
||
from .const import * | ||
import json | ||
|
||
# from homeassistant.helpers.entity import Entity | ||
from homeassistant.const import ( | ||
CONF_SCAN_INTERVAL, | ||
Platform | ||
) | ||
|
||
from .const import * | ||
|
||
async def async_setup(hass, config): | ||
hass.data.setdefault(DOMAIN, {}) | ||
"""Set up a skeleton component.""" | ||
# if DOMAIN not in config: | ||
# hass.states.async_set('sonnenbatterie.test', 'Works!') | ||
# return True | ||
|
||
# hass.states.async_set('sonnenbatterie.test', 'Works!') | ||
return True | ||
# rustydust_241227: this doesn't seem to be needed - kept until we're sure ;) | ||
# async def async_setup(hass, config): | ||
# """Set up a skeleton component.""" | ||
# hass.data.setdefault(DOMAIN, {}) | ||
# return True | ||
|
||
|
||
async def async_setup_entry(hass, config_entry): | ||
LOGGER.info("setup_entry: " + json.dumps(dict(config_entry.data))) | ||
|
||
LOGGER.debug("setup_entry: " + json.dumps(dict(config_entry.data))) | ||
await hass.config_entries.async_forward_entry_setups(config_entry, [ Platform.SENSOR ]) | ||
config_entry.add_update_listener(update_listener) | ||
# rustydust_241227: this doesn't seem to be needed | ||
# config_entry.add_update_listener(update_listener) | ||
config_entry.async_on_unload(config_entry.add_update_listener(async_reload_entry)) | ||
return True | ||
|
||
|
||
async def async_reload_entry(hass, entry): | ||
"""Reload config entry.""" | ||
await async_unload_entry(hass, entry) | ||
await async_setup_entry(hass, entry) | ||
"""Reload config entry.""" | ||
await async_unload_entry(hass, entry) | ||
await async_setup_entry(hass, entry) | ||
|
||
|
||
async def update_listener(hass, entry): | ||
LOGGER.info("Update listener" + json.dumps(dict(entry.options))) | ||
hass.data[DOMAIN][entry.entry_id]["monitor"].update_interval_seconds = ( | ||
entry.options.get(CONF_SCAN_INTERVAL) | ||
) | ||
# rustydust_241227: this doesn't seem to be needed | ||
# async def update_listener(hass, entry): | ||
# LOGGER.warning("Update listener" + json.dumps(dict(entry.options))) | ||
# # hass.data[DOMAIN][entry.entry_id]["monitor"].update_interval_seconds = ( | ||
# # entry.options.get(CONF_SCAN_INTERVAL) | ||
# # ) | ||
|
||
|
||
async def async_unload_entry(hass, entry): | ||
"""Handle removal of an entry.""" | ||
return await hass.config_entries.async_forward_entry_unload(entry, "sensor") | ||
return await hass.config_entries.async_forward_entry_unload(entry, Platform.SENSOR) |
Oops, something went wrong.