MySQL and Influx cant connect when running in docker

It is using Docker version 18.09.5, build e8ff056dbc

It is also possible to specify other templates, for installing some which isnt in the CA addon.

This is the template it use for the one I got in right now

<?xml version="1.0"?>
<Container version="2">
  <Name>openHAB</Name>
  <Repository>openhab/openhab:2.4.0-amd64-debian</Repository>
  <Registry>https://hub.docker.com/r/openhab/openhab/</Registry>
  <Network>br0</Network>
  <MyIP>192.168.1.35</MyIP>
  <Shell>sh</Shell>
  <Privileged>false</Privileged>
  <Support>https://forums.unraid.net/topic/78482-support-knex666-openhab/</Support>
  <Project>https://github.com/maschhoff/docker/tree/master/openhab</Project>
  <Overview>openHAB - a vendor and technology agnostic open source automation software for your home.&#xD;
&#xD;
For sample rules etc. have a look at https://github.com/maschhoff/OpenHAB</Overview>
  <Category>HomeAutomation:</Category>
  <WebUI>http://[IP]:[PORT:8080]/</WebUI>
  <TemplateURL/>
  <Icon>https://raw.githubusercontent.com/tinglis1/docker-containers/master/openhab/openhab-logo-square.png</Icon>
  <ExtraParams>--tty --shm-size 2g</ExtraParams>
  <PostArgs/>
  <CPUset/>
  <DateInstalled>1558954404</DateInstalled>
  <DonateText/>
  <DonateLink/>
  <Description>openHAB - a vendor and technology agnostic open source automation software for your home.&#xD;
&#xD;
For sample rules etc. have a look at https://github.com/maschhoff/OpenHAB</Description>
  <Networking>
    <Mode>br0</Mode>
    <Publish/>
  </Networking>
  <Data>
    <Volume>
      <HostDir>/etc/localtime</HostDir>
      <ContainerDir>/etc/localtime</ContainerDir>
      <Mode>ro</Mode>
    </Volume>
    <Volume>
      <HostDir>/mnt/user/appdata/openhab2/conf/</HostDir>
      <ContainerDir>/openhab/conf</ContainerDir>
      <Mode>rw</Mode>
    </Volume>
    <Volume>
      <HostDir>/mnt/user/appdata/openhab2/userdata/</HostDir>
      <ContainerDir>/openhab/userdata</ContainerDir>
      <Mode>rw</Mode>
    </Volume>
  </Data>
  <Environment/>
  <Labels/>
  <Config Name="Host Path 1" Target="/etc/localtime" Default="/etc/localtime" Mode="ro" Description="Container Path: /etc/localtime" Type="Path" Display="always" Required="true" Mask="false">/etc/localtime</Config>
  <Config Name="Host Path 2" Target="/openhab/conf" Default="/mnt/user/appdata/openhab/conf/" Mode="rw" Description="Container Path: /openhab/conf" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/openhab2/conf/</Config>
  <Config Name="Host Path 3" Target="/openhab/userdata" Default="/mnt/user/appdata/openhab/userdata/" Mode="rw" Description="Container Path: /openhab/userdata" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/openhab2/userdata/</Config>
</Container>

Okay.
Is your InfluxDB / MySQL Setup also Docker or Local setup?

The influxdb and mysql are also dockers. I can reach them from anywhere else on the network, and my openhab installation in a VM is also putting data into them.

I guess this is you old setup, since you try it now with docker.

No route to host

is stated in your openHAB error log.

<Networking>
    <Mode>br0</Mode>

This is in the template. But I already stated

Try to edit the template and change br0 to host

Yes, the VM is the old setup, but I like docker, because I dont have do dedicated resources to it, it can just take them as needed.

I already tried changing to host when I saw your first post, sadly that didnt fix the problem either.

Did you try to from inside the openHAB docker if you can even reach it?

docker exec it DOCKERID /bin/bash

I am not sure what you mean.

Should be able to connect to influx from inside the docker

Now I am not getting any errors… But it still isnt working either

2019-05-27 07:00:39.778 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Copenhagen'.
2019-05-27 07:00:39.786 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '0,0'.
2019-05-27 07:00:39.788 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'da_DK'.
2019-05-27 07:00:39.953 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2019-05-27 07:00:39.966 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2019-05-27 07:00:41.596 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'aircondition.items'
2019-05-27 07:00:41.638 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'workroom.items'
2019-05-27 07:00:41.651 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'common.items'
2019-05-27 07:00:41.826 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mysql.persist'
2019-05-27 07:00:41.839 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'influxdb.persist'
2019-05-27 07:00:42.628 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-05-27 07:00:42.789 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'nygade.sitemap'
2019-05-27 07:00:42.889 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'mqtt.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
2019-05-27 07:00:42.891 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mqtt.things'
2019-05-27 07:00:43.167 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.1.100:8080
2019-05-27 07:00:43.169 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.1.100:8443
2019-05-27 07:00:43.262 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2019-05-27 07:00:43.411 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.30' with clientid paho172348801358278 and file store '/openhab/userdata/mqtt/192.168.1.30'

Why did you create textual MQTT Things and not via PaperUI? Also you messed something up there.

Well let’s take a look at your influxdb.persist file :wink:

This is my crude, I don’t care, log everything file.

// Persistence Strategien haben einen Namen und eine Definition
Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    // Wenn bei einem unten definierten Item keine Strategie angebeben ist,
    // wird die Default-Liste angewendet
    default = everyChange
}

/*
 * Each line in this section defines for which item(s) which strategy(ies)
 * should be applied. You can list single items, use "*" for all items or
 * "groupitem*" for all members of a group item (excl. the group item itself).
 */
Items {
    // Speichere die Daten aller Items jeden Tag (veryDay), bei jeder Änderung (everyChange) und
    // ordne den Items bei einem Neustartand den letzten Wert zu (restoreOnStartup)
    * : strategy = everyChange, everyDay
}

Because I like having them in a text file.

As far as I can see, there is a bug where it validate it wrong, while it is fine.

influx.persist

Strategies {
  everyMinute : "0 * * * * ?"
  default = everyChange
}

Items {
  sensor* : strategy = everyMinute, restoreOnStartup
  startRestore* : strategy = everyChange, restoreOnStartup
}

aircondition.items

Number ac_water_level "Condensation water [%.0f %%]" <sewerage> (sensors) {channel="mqtt:topic:aircondition:water_level"}

mqtt.things

Bridge mqtt:broker:selina_mqtt [ host="192.168.1.30", secure=false ]
{
	Thing mqtt:topic:aircondition {
	Channels:
		Type number : water_level 	"AC water level" 	[ stateTopic="/AC/water_level" ]
	}
}

persist states

item def. states group name

I don’t know, is it like RegEx sonsor*? I would try sensors*

PS:
you can tail the influxdb logs to see if something (openHAB) accesses and writes values.

docker logs -f DOCKERID

On my old install I just use sensor* and then call sensorStuff it then include all the items which start with sensor

Increase influxdb logging in the openhab-cli

log:set TRACE org.openhab.persistence.influxdb

This way you can see what the influx binding is trying to do every change etc.

16:19:10.352 [TRACE] [b.internal.InfluxDBPersistenceService] - Tried to get item from item class class org.openhab.core.library.items.SwitchItem, state is ON
16:19:10.353 [INFO ] [smarthome.event.ItemStateChangedEvent] - BewegungsmelderKHlschrankGetrNke_MotionStatus changed from OFF to ON
16:19:10.358 [DEBUG] [b.internal.InfluxDBPersistenceService] - got OnOffType value 1
16:19:10.360 [TRACE] [b.internal.InfluxDBPersistenceService] - storing BewegungsmelderKHlschrankGetrNke_MotionStatus in influxdb value 1, BewegungsmelderKHlschrankGetrNke_MotionStatus (Type=SwitchItem, State=ON)

I got the debugging enabled, but it isn’t trying to store anything with the influxdb binding.

2019-05-27 09:03:31.050 [DEBUG] [org.openhab.persistence.influxdb    ] - BundleEvent STARTING - org.openhab.persistence.influxdb
2019-05-27 09:03:31.052 [DEBUG] [.InfluxDBPersistenceServiceActivator] - InfluxDB persistence bundle has been started.
2019-05-27 09:03:31.054 [DEBUG] [org.openhab.persistence.influxdb    ] - ServiceEvent REGISTERED - {org.osgi.service.cm.ManagedService}={service.id=358, service.bundleid=216, service.scope=singleton} - org.openhab.persistence.influxdb
2019-05-27 09:03:31.059 [DEBUG] [.internal.InfluxDBPersistenceService] - influxdb persistence service activated
2019-05-27 09:03:31.060 [DEBUG] [.internal.InfluxDBPersistenceService] - using default retentionPolicy autogen
2019-05-27 09:03:31.181 [DEBUG] [.internal.InfluxDBPersistenceService] - database status is OK, version is 1.7.6
2019-05-27 09:03:31.228 [DEBUG] [org.openhab.persistence.influxdb    ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService, org.openhab.core.persistence.QueryablePersistenceService}={password=xxxxxxxxxxxxxx, service.id=359, service.bundleid=216, service.scope=bundle, user=openhab, url=http://192.168.1.100:8086, service.pid=org.openhab.influxdb, component.name=org.openhab.persistence.influxdb, db=openhab, component.id=219} - org.openhab.persistence.influxdb
2019-05-27 09:03:31.230 [DEBUG] [org.openhab.persistence.influxdb    ] - BundleEvent STARTED - org.openhab.persistence.influxdb

Just to rule out the wildcard in the persistance, I also tried to edit the file

Strategies {
  everyMinute : "0 * * * * ?"
  default = everyChange
}

Items {
  sensor : strategy = everyMinute, restoreOnStartup
  startRestore* : strategy = everyChange, restoreOnStartup
}

and also call the waterlevel sensor just (sensor) and I tried with sensor* in the persist file too

I now gow both Influxdb and MySQL. I am not sure what changed from the first time I tried to change to host, to the last time I tried again.

Now now both can connect to the databases.

I must be doing something wrong in my persist files, because adding a * item for the strategy, made them work.

Strategies {
  everyMinute : "0 * * * * ?"
  every15Minute : "0 0/15 * * * ?"
  default = everyChange
}

Items {
  sensor : strategy = everyChange, every15Minute, restoreOnStartup
  startRestore* : strategy = everyChange, restoreOnStartup
  * : strategy = everyChange
}

Maybe there was something in the change log from your older version to the current version.

Going to investigate a bit further, but at least it works a bit better now :slight_smile:

Thank you for your help and patience, I did learn some new things, including how to access the openhab console :slight_smile:

Oopps… from what I read from I thought you already had that skill.
The next time I try to support someone I will try to ask for the “skill” level.

I did figure it out :wink: A bit of google magic, and I was in :smiley:

That is not how .persist files have ever worked. The * stands for “all members of this Group”. So you would need to create a Group named “sensor” and add “sensorStuff” to that Group for it to be persisted using “sensor*” in a .persist file. This is documented in Persistence | openHAB