Mas2112 / solarwatt-energymanager-homeassistant

A SOLARWATT EnergyManager Home Assistant custom component.
MIT License
17 stars 3 forks source link

Update hostname/IP address of energy manager without re-initialization of integration? #18

Closed chrizzzp closed 7 months ago

chrizzzp commented 7 months ago

Hi, I'm running HA supervised and use the integration with a "Solarwatt-clone" (rebranded) energy manager. Retrieval of data from the energy manager normally works and HA entities are generated and updated. The energy manager is accessed by it's local host name (energymanager.local) accessing e.g. http://energymanager.local/rest/kiwigrid/wizard/devices.

From time to time I have the strange (and still unresolved) problem that the hostname (energymanager.local) somehow becomes unknown in the local network and the integration cannot connect to the energy manager by its hostname any longer. Access via the IP address is still possible, though (e.g. http://192.168.178.80/rest/kiwigrid/wizard/devices). Rebooting the energy manager fixes the problem, but this is not something I'm keen on doing too often.

So now I would like to change configuration of the HA integration in a way that the IP address is directly used (instead of hostname) to retrieve the data from the energy manager.

Can I achieve this by editing some configuration file of the integration? Reason is that I don't want to reinstall the integration (and energy manager) which would (probably) mean I loose my current energy manager entities (and statistics). They are used in several active automations.

In the HA/custom_components/solarwatt_energymanager directory I found the following file const.py:

"""Constants for the solarwatt_energymanager integration."""

DOMAIN = "solarwatt_energymanager"
CONFIG_HOST = "host"
POLL_INTERVAL = "poll_interval"
DEFAULT_POLL_INTERVAL = 10
ENERGY_MANAGER = "energy_manager"

Can I edit this file and replace 'host' with the IP address of the energy manager? (Sorry if this a stupid idea...)

Thanks!

Mas2112 commented 7 months ago

It's not so obvious how to change the config.

You need to edit

/config/.storage/core.config_entries

This is a giant JSON file. Look for the string solarwatt_energymanager and there you will find a "data" entry, under which the host name is stored.

You should be able to change this there. You will probably need to restart the integration somehow, perhaps by rebooting.

chrizzzp commented 7 months ago

Excellent, thank you! I reloaded the integration (without rebooting), hope this was sufficient. At least data keep coming in...