add reconnect timer

This commit is contained in:
Nitwel 2024-05-06 13:34:56 +02:00
parent 76ad1f11f4
commit 51fbe99722

View File

@ -29,11 +29,23 @@ signal on_disconnect()
## The current home automation system adapter ## The current home automation system adapter
var api: Node var api: Node
var reconnect_timer := Timer.new()
func _ready(): func _ready():
print("HomeApi ready") print("HomeApi ready")
start() start()
reconnect_timer.wait_time = 60
reconnect_timer.one_shot = false
reconnect_timer.autostart = true
add_child(reconnect_timer)
reconnect_timer.timeout.connect(func():
if has_connected() == false:
start()
)
## Starts the adapter with the settings from the settings file ## Starts the adapter with the settings from the settings file
func start(): func start():
var success = Store.settings.load_local() var success = Store.settings.load_local()