Help with RPI Openhab full hang. (WAS Rule for longest ever uptime?)

(Aaron) #12


It says that this will install influxdB and grafana but it can not like the two together at the moment please see a community post…

I’m assuming Openhabian is for beginners it makes getting oh running easy and has things like frontail smb shares ect already installed I’m sure you already know tho :wink:

Let me take my system offline and image my sd card :frowning: i always do before messing with important stuff

I will run the command and see what happens will post back

(Aaron) #13


I have Finished that now it said setup successful onscreen readings at bottom of this post

I’m not sure what too do next its directed me too the same post as you posted

having a scroll through too see if i can find answers

im not after setting grafana up atm although i can access a logon page for grafana from the OH Start Page

but getting influx working would be nice

I have tried too access the webfrontend by typing in into my browser it brings up a 404 error (Google says the web frontend has been removed since v1.3) ?

where should i type the commands from the post you linked too create the database / users after i have SSH into the RPI Here ?

What was said onscreen during install i have since done the updates still stuck

2018-07-16_20:44:54_BST [openHABian] Checking for changes in origin... OK
2018-07-16_20:45:01_BST [openHABian] Setting up InfluxDB and Grafana...

$ apt -y install apt-transport-https
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (1.4.8).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

--2018-07-16 20:45:40--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3108 (3.0K) [application/pgp-keys]
Saving to: ‘STDOUT’

-                                         100%[=====================================================================================>]   3.04K  --.-KB/s    in 0s

2018-07-16 20:45:40 (40.3 MB/s) - written to stdout [3108/3108]


$ apt update
Get:1 stretch InRelease [15.0 kB]
Get:2 stretch InRelease [25.3 kB]
Ign:3 stable InRelease
Hit:4 stable Release
Ign:5 stable InRelease
Get:6 stretch InRelease [4,732 B]
Hit:7 stable Release
Hit:8 stretch InRelease
Get:9 stretch/main armhf Packages [11.7 MB]
Get:10 stretch/ui armhf Packages [34.0 kB]
Get:12 stretch/contrib armhf Packages [56.9 kB]
Get:13 stretch/stable armhf Packages [925 B]
Fetched 11.8 MB in 10s (1,137 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
18 packages can be upgraded. Run 'apt list --upgradable' to see them.

$ apt -y install influxdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.
Need to get 21.3 MB of archives.
After this operation, 66.6 MB of additional disk space will be used.
Get:1 stretch/stable armhf influxdb armhf 1.6.0-1 [21.3 MB]
Fetched 21.3 MB in 3s (5,423 kB/s)
Selecting previously unselected package influxdb.
(Reading database ... 47418 files and directories currently installed.)
Preparing to unpack .../influxdb_1.6.0-1_armhf.deb ...
Unpacking influxdb (1.6.0-1) ...
Setting up influxdb (1.6.0-1) ...
Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
Created symlink /etc/systemd/system/ → /lib/systemd/system/influxdb.service.
Processing triggers for man-db ( ...
Updating FireMotD available updates count ...

$ systemctl daemon-reload

$ systemctl enable influxdb.service

$ systemctl start influxdb.service

$ apt-key adv --keyserver --recv-keys 
Executing: /tmp/apt-key-gpghome.RqmtlxTanG/ --keyserver --recv-keys 
gpg: key : public key "Bintray (by JFrog) <>" imported
gpg: Total number processed: 1
gpg:               imported: 1

$ apt update
Hit:1 stretch InRelease
Hit:2 stretch InRelease
Ign:3 stable InRelease
Hit:4 stable Release
Hit:5 stretch InRelease
Hit:6 stretch InRelease
Ign:7 stretch InRelease
Ign:8 stable InRelease
Get:9 stretch Release [5,300 B]
Hit:10 stable Release
Get:11 stretch Release.gpg [821 B]
Get:14 stretch/main armhf Packages [1,784 B]
Fetched 7,905 B in 3s (2,163 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
18 packages can be upgraded. Run 'apt list --upgradable' to see them.

$ apt -y install grafana
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.
Need to get 48.5 MB of archives.
After this operation, 131 MB of additional disk space will be used.
Get:1 stretch/main armhf grafana armhf 5.1.4 [48.5 MB]
Fetched 48.5 MB in 1min 15s (645 kB/s)
Selecting previously unselected package grafana.
(Reading database ... 47444 files and directories currently installed.)
Preparing to unpack .../grafana_5.1.4_armhf.deb ...
Unpacking grafana (5.1.4) ...
Processing triggers for systemd (232-25+deb9u2) ...
Setting up grafana (5.1.4) ...
Adding system user `grafana' (UID 111) ...
Adding new user `grafana' (UID 111) with group `grafana' ...
Not creating home directory `/usr/share/grafana'.
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
 sudo /bin/systemctl daemon-reload
 sudo /bin/systemctl enable grafana-server
### You can start grafana-server by executing
 sudo /bin/systemctl start grafana-server
Processing triggers for systemd (232-25+deb9u2) ...
Updating FireMotD available updates count ...

$ systemctl daemon-reload

$ systemctl enable grafana-server.service
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/grafana-server.service.

$ systemctl start grafana-server.service
Connecting (TODO)...
Adding openHAB dashboard tile...
2018-07-16_20:48:23_BST [openHABian] Adding an openHAB dashboard tile for 'grafana'... OK
2018-07-16_20:48:36_BST [openHABian] Checking for default openHABian username:password combination... OK
2018-07-16_20:48:36_BST [openHABian] We hope you got what you came for! See you again soon ;)

(Rich Koshak) #14

since you are in the InfluxDB shell I think you just type in the commands there.

(Aaron) #15

Hi Rich

I have typed the commands there i wasen’t sure i was in the right place im still new too this

i Still cant access the web frontend for influx
grafana seems too be working not joined with influx but working

i have edited the text config files too

I new this would be tricky I can’t work out what I need too do now or next im getting tired too so that never helps

Any hints appreciated

I am picking some of the linux stuff up and am. Enjoying it at the same time it’s just slightly different than I’m used too with windows

(Rich Koshak) #16

It may be gone. It was deprecated shortly after that tutorial was written but still hanging around and usable. I guess they finally just dropped it entirely.

Reading through the Influxdb+grafana tutorial it doesn’t mention anything about the web based interface for InfluxDB. What tutorial are you following?

(Aaron) #17


I’m following the one posted above

But I didn’t install influx or grafana myself I used the openhabian-config add component and followed the guide it linked me too again it was the same one posted above

What is the monitering host? I’m not sure about this


  1. I used the openhabian-config to install the influx and grafana packages

It told me too follow the guide posted above I did
The parts influxdb install and setup

2)Entered the commands in the influx cli (created users and dB)

3)I then changed the influx.config

restarted influx

I didn’t inject data

4)I tried too connect too OH installed influx persistence edited influx.cfg

5)Created a persist file

Rebooted rpi

(Rich Koshak) #18

It’s the machine where you installed InfluxDB.

You have yet to indicate what, if anything, the problem is. Are you seeing errors? If so what are they? Is persistence not working? If not then how are you checking?

(Aaron) #19

Ok so I don’t have too really worry about that it’s installed on the same rpi

Yes the problems just getting it working so I can start using the rules posted above

I’m just struggling with what too actually do maby it’s just not working as expected getting mapdb and rrd4j running was easy I have just been checking the persistence folder for files created by influx but I don’t know how too check the simple stuff like if the actual influx dB is running as it told me it’s accessible on localhost:8086 and then I couldent access it there

(Vincent Regaud) #20

Did you install the influxdb persistence service in OH?
Do you get any influxdb related error messages when you start OH?

(Aaron) #21


I have installed it yes

I have just put the log in debug mode it is saying stuff about

got DecimalType value 24.61

got onoff type value 1

I have been using the frontail Web log and haven’t seen anything there or should I check somewhere else?


I’m not trying too be rude or short I’m just very tired I do actually appreciate the help from you all

(Rich Koshak) #22

InfluxDB is a whole separate thing from OH. rrd4j and mapdb are what are called embedded databases. They run inside of OH. InfluxDB is its own software with its own places to store data and such. It doesn’t store anything in the persistence folder of OH. It actually stores it’s data in /var/lib/influxdb/data. You should see an openhab_db folder in there. You can dig further but the folders and files and such will make no sense to you (or me for that matter).

It is accessible on localhost:8086 using InfluxDB’s protocol. That doesn’t mean it runs a webpage on that port. That is how OH talks to InfluxDB. The way you talk to InfluxDB is through the interface that you typed in the command to create the database and such previously.

So you can either run a query from that influx command prompt, see the InfluxDB docs for how to do that (I don’t know off the top of my head). Or you can run a query from the OH REST API under persistence. Just be sure to supply influxdb and your Item name for the /persistence/items/{itemname} endpoint.

If there are no errors it is either not installed, not configured, or working just fine. Since you installed the influxdb binding, configured an influxdb.persist file and influxdb.cfg file then it is probably working.

(Aaron) #23


Thank you

I already knew some of that but the parts I didn’t have filled in alot of gaps mainly the way I talk too influx and the way oh does and where the files are stored

I could not have asked for a better explanation

I’m going too look in the location for the dB file you said

(Aaron) #24


OK found the file openhab_dB does exist in the folder you said

Should I be able too use the rules posted above now

(Rich Koshak) #25

I would assume so.

(Aaron) #26

I’m going too try later now I’m more refreshed

I have moved one of my timeline graphs over in habpannel seems too be working thanks for helping lastnight my brain was fried

(Aaron) #27

I have changed my graphs and persistence from rrd4j and uninstalled rrd4j working fine not tried grafana yet although my graphs are already alot nicer now

But I have tried the rule posted above getting an error about NULL

2018-07-17 21:46:21.082 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test Rule': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

I have created the new item and added this too the influx persistence

Number Longestuptime28days "Longest uptime in 28 days" <calander>

edited rule from above

rule "Test Rule"
    Item Systemuptime changed

persistence file shortened
is this setup right i wanted too persist items on changes only but my graphs didnt work when removing everyminute

Strategies {
    everyMinute : "0 * * * * ?"

Items {
    Ghouse_Light_Level : strategy = everyChange, everyMinute

(Scott Rushworth) #28

IIRC, you would need a value from 28 days ago to do maximumSince(now.minusDays(28)). So, you will need to wait, or put an entry in the database with an appropriate date.

(Aaron) #29

Hi again

Thanks for your help again

If that’s the case that’s perfectly fine i just thought it was wrong should i change it too something like 2 days too get a test result faster 28 day wait is a long time i might forget i’m waiting lol

but im going too have too wait for ever for the forever result

i would prefer too leave it i dont have the correct data anyway

(Rich Koshak) #30

Systemuptime is also a Number? I would assume so but it is always good to check.

I’m assuming that maximiumSince returns a Number Object, but perhaps it returns a primitive.

Or this is one of those cases where the Rules DSL just can’t figure out that there is a toString method it can call.

Or maybe it’s returning a HistoricState Item.

In the interest of time I would try the following until it works or doesn’t.

  • Systemuptime.maximumSince(now.minusDays(28).toString // sendCommand can always take a String
  • Systemuptime.maximumSince(now.minusDays(28) as Number // should already be a Number but perhaps it isn't
  • Systemuptime.maximumSince(now.minusDays(28).state // need to call .state if it is a HistoricItem

Double check that you are actually getting a value and not null. Calls to persistence will return null if there is a problem.

Have you change the default persistence to influxdb? If not you need to tell OH what persistence to query.

Systemuptime.maximumSince(now.minusDays(28, "influxdb")) // I forget whether the db name goes first or second

everyMinute is only required by rrd4j. But in Grafana you have lots of options to select from on how to deal with gaps in the data. In particular pay attention to the fill option for the data point. By default it is “null” which means don’t put a point on the graph if there isn’t one in the DB. If you choose something like last then it will bridge the gap in the graph using the previous value.

Doing experiments like this should be your number one tool to grab when trying to figure out a problem. It’s such a trivial change to make you could of had your answer in the time it took you to ask the question in the first place. Don’t be afraid to experiment. The backups are there for a reason.

(Aaron) #31

Hi Again

I have also tried String , Yes its a Number Item

I will try and post back im not sure about the formatting of the brackets i have tried them all but the brackets might be off

Longestuptime28days.sendCommand(Systemuptime.maximumSince(now.minusDays(28) as Number))

Could you point me in the right direction on how too do this ?

Yes and uninstalled the rrd4j persistence and deleted its db files and persistence file

I will try this too

so i can actually remove this then i’m definitely not using rrd4j now but i’m also not using grafana yet either i’m just using timelines on habpannel and also interactive charts on habpannel

i would still have too wait two days if @5iver is right about having too wait just 2 days is less wait than 28 :wink:

Error Received trying
Longestuptime28days.sendCommand(Systemuptime.maximumSince(now.minusDays(28) as Number))

 Validation issues found in configuration model 'New.rules', using it anyway:

Cannot cast from DateTime to Number

2018-07-17 22:42:21.455 [vent.ItemStateChangedEvent] - Systemuptime changed from 1453.6 to 1457.6

==> /var/log/openhab2/openhab.log <==

2018-07-17 22:42:21.793 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test Rule': Could not cast 2018-07-16T22:42:21.779+01:00 to java.lang.Number; line 61, column 63, length 26

Error Received trying

2018-07-17 22:46:21.488 [vent.ItemStateChangedEvent] - Systemuptime changed from 1457.6 to 1461.6

==> /var/log/openhab2/openhab.log <==

2018-07-17 22:46:22.194 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test Rule': 'state' is not a member of 'org.joda.time.DateTime'; line 61, column 63, length 22

I also changed the days from 28 to 1