add hex_to_float option

add auto config reload on megad restart
fix reloading issues
This commit is contained in:
Andrey
2021-03-05 11:45:41 +03:00
parent 84f677656a
commit 149d30e921
3 changed files with 15 additions and 20 deletions

View File

@@ -65,13 +65,13 @@ class MegaD:
def __init__(
self,
hass: HomeAssistant,
config: ConfigEntry,
loop: asyncio.AbstractEventLoop,
host: str,
password: str,
mqtt: mqtt.MQTT,
lg: logging.Logger,
id: str,
config: ConfigEntry = None,
mqtt_inputs: bool = True,
mqtt_id: str = None,
scan_interval=60,
@@ -625,7 +625,7 @@ class MegaD:
stime=datetime.now().strftime('%H:%M:%S')
)
async def reload(self):
async def reload(self, reload_entry=True):
new = await self.get_config(nports=self.nports)
self.lg.debug(f'new config: %s', new)
cfg = dict(self.config.data)
@@ -633,4 +633,5 @@ class MegaD:
cfg.pop(x, None)
cfg.update(new)
self.config.data = cfg
await self.hass.config_entries.async_reload(self.config.entry_id)
if reload_entry:
await self.hass.config_entries.async_reload(self.config.entry_id)