Skip to content

Commit

Permalink
0.9.6.12 - Bug fix for Panel Number Update
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmeghead committed Aug 4, 2024
1 parent a3d2cb1 commit f938272
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
16 changes: 16 additions & 0 deletions custom_components/visonic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
}
)

update_version_panel_number = 0

# Create the types for the Configuration Parameter Entry
VisonicConfigKey: HassEntryKey["VisonicConfigData"] = HassEntryKey(DOMAIN)
type VisonicConfigEntry = ConfigEntry[VisonicConfigData]
Expand Down Expand Up @@ -377,6 +379,20 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: VisonicConfigEn
hass.config_entries.async_update_entry(config_entry, data=new, options=new, version=version)
_LOGGER.debug(" Alarm Notification list set to default")

if version == 3:
version = 4
new = config_entry.data.copy()

if CONF_PANEL_NUMBER not in new:
# We have to assume that multiple panels will be updated at the same time, otherwise it gets complicated
_LOGGER.debug(f" Migrating Panel Number, using {update_version_panel_number}")
new[CONF_PANEL_NUMBER] = update_version_panel_number
update_version_panel_number = update_version_panel_number + 1
else:
_LOGGER.debug(f" Panel Number already set to {new[CONF_PANEL_NUMBER]} so updating config version number only")

hass.config_entries.async_update_entry(config_entry, data=new, options=new, version=version)

_LOGGER.info("Migration to version %s successful", config_entry.version)
return True

Expand Down
2 changes: 1 addition & 1 deletion custom_components/visonic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
# "trigger",
#]

CLIENT_VERSION = "0.9.6.10"
CLIENT_VERSION = "0.9.6.12"

MAX_CLIENT_LOG_ENTRIES = 300

Expand Down
4 changes: 2 additions & 2 deletions custom_components/visonic/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async def processcomplete(self):
class VisonicConfigFlow(ConfigFlow, MyHandlers, domain=DOMAIN):
"""Handle a Visonic flow."""

VERSION = 3
VERSION = 4
CONNECTION_CLASS = CONN_CLASS_LOCAL_POLL

def __init__(self):
Expand Down Expand Up @@ -345,7 +345,7 @@ async def async_step_import(self, import_config):
class VisonicOptionsFlowHandler(OptionsFlow, MyHandlers):
"""Handle options."""

VERSION = 1
VERSION = 4
CONNECTION_CLASS = CONN_CLASS_LOCAL_POLL

def __init__(self, config_entry : ConfigEntry):
Expand Down
12 changes: 7 additions & 5 deletions custom_components/visonic/examples/complete_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from enum import Enum
from pyvisonic import VisonicProtocol
import socket
from inspect import currentframe, getframeinfo, stack

# Try to import aconsole, if it fails then print an error message
try:
Expand Down Expand Up @@ -906,17 +907,18 @@ async def shutdown(loop, signal=None):
await asyncio.gather(*tasks, return_exceptions=True)
loop.stop()



if __name__ == '__main__':
# Set up the asyncio first and then we don't get the debug data messages
testloop = asyncio.new_event_loop()
asyncio.set_event_loop(testloop)
testloop.set_exception_handler(handle_exception)

setupLocalLogger("ERROR", empty = True) # one of "WARNING" "INFO" "ERROR" "DEBUG"
ConfigureLogger(str(args.print).lower(), None)
setConnectionMode(str(args.connect).lower())

testloop = asyncio.get_event_loop()
testloop.set_exception_handler(handle_exception)

client = VisonicClient(loop = testloop, config = myconfig)

if client is not None:
success = True #client.connect(wait_sleep=False, wait_loop=True)
if success:
Expand Down

0 comments on commit f938272

Please sign in to comment.