bwssytems / ha-bridge

Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge.
Apache License 2.0
1.45k stars 199 forks source link

ha-bridge.config not readable #1365

Open niawag opened 2 years ago

niawag commented 2 years ago

Hi and thanks for ha-bridge, it is a great piece of software!

I'm facing an occasional issue on my install, it runs on a Pi3 and is installed using docker with a pretty simple compose file:

  habridge:
    container_name: habridge
    image: lscr.io/linuxserver/habridge
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
    volumes:
      - ../habridge:/config
    network_mode: host
    restart: unless-stopped

All is working fine except it occasionally fails to run because the config file ha-bridge.config is emptied. I don't know what causes it to be emptied it happens after "dirty" reboots (caused by watchdog). The log concerning this is here:

2022-05-31 20:47:31,222 [main] INFO  com.bwssystems.HABridge.HABridge - HA Bridge startup sequence...
2022-05-31 20:47:32,132 [main] INFO  com.bwssystems.HABridge.HABridge - HA Bridge (v5.4.1) initializing....
2022-05-31 20:47:32,142 [main] INFO  com.bwssystems.HABridge.BridgeSettings - reading from config file: /config/ha-bridge.config
2022-05-31 20:47:32,538 [main] WARN  com.bwssystems.HABridge.BridgeSettings - Issue loading values from file: file:///config/ha-bridge.config, Gson convert failed. Using default settings.
2022-05-31 20:47:32,559 [main] INFO  com.bwssystems.HABridge.BridgeSettings - Adding 192.168.0.44 as our default upnp config address.
2022-05-31 20:47:32,662 [main] INFO  spark.staticfiles.StaticFilesConfiguration - StaticResourceHandler configured with folder = /public
2022-05-31 20:47:32,760 [main] INFO  com.bwssystems.HABridge.SystemControl - System control service started....
2022-05-31 20:47:33.007:INFO::Thread-0: Logging initialized @3873ms to org.eclipse.jetty.util.log.StdErrLog
2022-05-31 20:47:33,189 [main] INFO  com.bwssystems.HABridge.util.UDPDatagramSender - Initializing UDP response Socket...
2022-05-31 20:47:33,203 [main] INFO  com.bwssystems.HABridge.util.UDPDatagramSender - UDP response Socket initialized to: 50000
2022-05-31 20:47:33,229 [main] INFO  com.bwssystems.HABridge.plugins.http.HTTPHome - HTTP Home created.
2022-05-31 20:47:33,257 [main] INFO  com.bwssystems.HABridge.plugins.harmony.HarmonyHome - Harmony Home created. No Harmony devices configured.
2022-05-31 20:47:33,267 [main] INFO  com.bwssystems.HABridge.plugins.NestBridge.NestHome - Nest Home created. No Nest configured.
2022-05-31 20:47:33,274 [main] INFO  com.bwssystems.HABridge.plugins.hue.HueHome - Hue passthru Home created. No Hue passtrhu systems configured.
2022-05-31 20:47:33,282 [main] INFO  com.bwssystems.HABridge.plugins.hal.HalHome - HAL Home created. No HAL devices configured.
2022-05-31 20:47:33,289 [main] INFO  com.bwssystems.HABridge.plugins.mqtt.MQTTHome - MQTT Home created. No MQTT Clients configured.
2022-05-31 20:47:33,296 [main] INFO  com.bwssystems.HABridge.plugins.hass.HassHome - HomeAssistant Home created. No HomeAssistants configured.
2022-05-31 20:47:33,302 [main] INFO  com.bwssystems.HABridge.plugins.homewizard.HomeWizardHome - HomeWizard Home created. No HomeWizard gateways configured.
2022-05-31 20:47:33,310 [main] INFO  com.bwssystems.HABridge.plugins.exec.CommandHome - Command Home for system program execution created.
2022-05-31 20:47:33,317 [main] INFO  com.bwssystems.HABridge.plugins.tcp.TCPHome - TCP Home created.
2022-05-31 20:47:33,328 [main] INFO  com.bwssystems.HABridge.plugins.udp.UDPHome - UDP Home created.
2022-05-31 20:47:33,334 [main] INFO  com.bwssystems.HABridge.plugins.vera.VeraHome - Vera Home created. No Veras configured.
2022-05-31 20:47:33,341 [main] INFO  com.bwssystems.HABridge.plugins.fibaro.FibaroHome - Fibaro Home created. No Fibaros configured.
2022-05-31 20:47:33,349 [main] INFO  com.bwssystems.HABridge.plugins.domoticz.DomoticzHome - Domoticz Home created. No Domoticz devices configured.
2022-05-31 20:47:33,355 [main] INFO  com.bwssystems.HABridge.plugins.somfy.SomfyHome - Somfy Home created.  No Somfys configured.
2022-05-31 20:47:33,379 [main] INFO  com.bwssystems.HABridge.plugins.lifx.LifxHome - LifxDevice Home created. No LifxDevices configured.
2022-05-31 20:47:33,396 [main] INFO  com.bwssystems.HABridge.plugins.openhab.OpenHABHome - OpenHAB Home created. No OpenHABs configured.
2022-05-31 20:47:33,404 [main] INFO  com.bwssystems.HABridge.plugins.fhem.FHEMHome - FHEM Home created. No FHEMs configured.
2022-05-31 20:47:33,425 [main] INFO  com.bwssystems.HABridge.plugins.broadlink.BroadlinkHome - Broadlink Home created. No Broadlinks configured.
2022-05-31 20:47:33,432 [main] INFO  com.bwssystems.HABridge.plugins.moziot.MozIotHome - Mozilla IOT Home created. No Mozilla IOTs configured.
2022-05-31 20:47:33,439 [main] INFO  com.bwssystems.HABridge.plugins.homegenie.HomeGenieHome - HomeGenie Home created. No HomeGenies configured.
2022-05-31 20:47:33,461 [main] WARN  com.bwssystems.HABridge.dao.DeviceRepository - Error reading the file: data/device.db - Does not exist or is not readable. continuing...
2022-05-31 20:47:33,470 [main] INFO  com.bwssystems.HABridge.devicemanagmeent.DeviceResource - HABridge device management service started....
2022-05-31 20:47:33,521 [Thread-0] INFO  spark.embeddedserver.jetty.EmbeddedJettyServer - == Spark has ignited ...
2022-05-31 20:47:33,523 [Thread-0] INFO  spark.embeddedserver.jetty.EmbeddedJettyServer - >> Listening on 0.0.0.0:80
2022-05-31 20:47:33.552:INFO:oejs.Server:Thread-0: jetty-9.4.z-SNAPSHOT, build timestamp: 2017-11-21T22:27:37+01:00, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
2022-05-31 20:47:33,784 [main] INFO  com.bwssystems.HABridge.hue.HueMulator - Hue emulator service started....
2022-05-31 20:47:33.865:INFO:oejs.session:Thread-0: DefaultSessionIdManager workerName=node0
2022-05-31 20:47:33.867:INFO:oejs.session:Thread-0: No SessionScavenger set, using defaults
2022-05-31 20:47:33.888:INFO:oejs.session:Thread-0: Scavenging every 660000ms
2022-05-31 20:47:33,945 [Thread-0] ERROR com.bwssystems.HABridge.HABridge - Could not start ha-bridge webservice on port [80] due to: Address in use
2022-05-31 20:47:33,950 [Thread-0] WARN  com.bwssystems.HABridge.HABridge - {"control":"stopping"}
2022-05-31 20:47:34,284 [main] INFO  com.bwssystems.HABridge.upnp.UpnpSettingsResource - Description xml service started....
2022-05-31 20:47:34,326 [main] WARN  com.bwssystems.HABridge.upnp.UpnpListener - UPNP Listener exiting as reinit or stop requested....
2022-05-31 20:47:34,327 [main] INFO  com.bwssystems.HABridge.HABridge - Going to close all homes
2022-05-31 20:47:34,329 [main] INFO  com.bwssystems.HABridge.HomeManager - Manager close homes called....
2022-05-31 20:47:34,331 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.tcp.TCPHome
2022-05-31 20:47:34,332 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.NestBridge.NestHome
2022-05-31 20:47:34,334 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hal.HalHome
2022-05-31 20:47:34,335 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.NestBridge.NestHome
2022-05-31 20:47:34,337 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.lifx.LifxHome
2022-05-31 20:47:34,338 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.somfy.SomfyHome
2022-05-31 20:47:34,340 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.moziot.MozIotHome
2022-05-31 20:47:34,341 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,343 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.openhab.OpenHABHome
2022-05-31 20:47:34,344 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hal.HalHome
2022-05-31 20:47:34,346 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.homewizard.HomeWizardHome
2022-05-31 20:47:34,347 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.fhem.FHEMHome
2022-05-31 20:47:34,349 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,350 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.udp.UDPHome
2022-05-31 20:47:34,352 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hal.HalHome
2022-05-31 20:47:34,353 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.broadlink.BroadlinkHome
2022-05-31 20:47:34,355 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.exec.CommandHome
2022-05-31 20:47:34,356 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,358 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hass.HassHome
2022-05-31 20:47:34,359 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.harmony.HarmonyHome
2022-05-31 20:47:34,360 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hal.HalHome
2022-05-31 20:47:34,362 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.homegenie.HomeGenieHome
2022-05-31 20:47:34,363 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.udp.UDPHome
2022-05-31 20:47:34,365 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.hue.HueHome
2022-05-31 20:47:34,366 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.harmony.HarmonyHome
2022-05-31 20:47:34,368 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.tcp.TCPHome
2022-05-31 20:47:34,369 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,371 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.mqtt.MQTTHome
2022-05-31 20:47:34,372 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.domoticz.DomoticzHome
2022-05-31 20:47:34,374 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,375 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.exec.CommandHome
2022-05-31 20:47:34,377 [main] INFO  com.bwssystems.HABridge.HomeManager - Closing home: com.bwssystems.HABridge.plugins.http.HTTPHome
2022-05-31 20:47:34,383 [Thread-10] INFO  spark.embeddedserver.jetty.EmbeddedJettyServer - >>> Spark shutting down ...
2022-05-31 20:47:34.410:INFO:oejs.AbstractConnector:Thread-10: Stopped ServerConnector@49cd0e{HTTP/1.1,[http/1.1]}{0.0.0.0:80}
2022-05-31 20:47:34.416:INFO:oejs.session:Thread-10: Stopped scavenging
2022-05-31 20:47:34,430 [Thread-10] INFO  spark.embeddedserver.jetty.EmbeddedJettyServer - done
2022-05-31 20:47:35,472 [main] ERROR com.bwssystems.HABridge.BridgeSettings - Error creating the directory: data/habridge.config message: /run/s6/services/ha-bridge/data
java.nio.file.AccessDeniedException: /run/s6/services/ha-bridge/data
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
        at java.nio.file.Files.createDirectory(Files.java:674)
        at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
        at java.nio.file.Files.createDirectories(Files.java:767)
        at com.bwssystems.HABridge.BridgeSettings.configWriter(BridgeSettings.java:315)
        at com.bwssystems.HABridge.BridgeSettings.updateConfigFile(BridgeSettings.java:302)
        at com.bwssystems.HABridge.HABridge.main(HABridge.java:142)
2022-05-31 20:47:35,480 [main] ERROR com.bwssystems.HABridge.BridgeSettings - Error writing the file: data/habridge.config message: data/habridge.config
java.nio.file.NoSuchFileException: data/habridge.config
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
        at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
        at java.nio.file.Files.newOutputStream(Files.java:216)
        at java.nio.file.Files.write(Files.java:3292)
        at com.bwssystems.HABridge.BridgeSettings.configWriter(BridgeSettings.java:327)
        at com.bwssystems.HABridge.BridgeSettings.updateConfigFile(BridgeSettings.java:302)
        at com.bwssystems.HABridge.HABridge.main(HABridge.java:142)
2022-05-31 20:47:35,485 [main] WARN  com.bwssystems.HABridge.BridgeSettings - Error reading the file: data/habridge.config - Does not exist or is not readable. continuing...
2022-05-31 20:47:40,117 [main] INFO  com.bwssystems.HABridge.plugins.http.HttpClientPool - Shutting down client pool
2022-05-31 20:47:40,126 [main] INFO  com.bwssystems.HABridge.plugins.http.HttpClientPool - Client pool shut down
2022-05-31 20:47:40,157 [main] INFO  com.bwssystems.HABridge.plugins.http.HttpClientPool - Instantiated SSL components.
2022-05-31 20:47:40,170 [main] INFO  com.bwssystems.HABridge.plugins.http.HttpClientPool - Shutting down client pool
2022-05-31 20:47:40,172 [main] INFO  com.bwssystems.HABridge.plugins.http.HttpClientPool - Client pool shut down
2022-05-31 20:47:40,173 [main] INFO  com.bwssystems.HABridge.HABridge - HA Bridge (v5.4.1) exiting....
2022-05-31 20:47:40,178 [Thread-1] INFO  com.bwssystems.HABridge.ShutdownHook - Shutdown requested...
2022-05-31 20:47:40,180 [Thread-1] INFO  com.bwssystems.HABridge.ShutdownHook - Already stopped

I've made a backup of ha-bridge.config and, when this occurs, I can easily restore the backup but I wonder why it happens and if I could prevent that?