Use information in human readable language in Habpanel

Hi all,

I am currently trying to set up a kind of log box on my openhabpanel. Thus I can see which things happened the last time and why certain rules fired in this or that way.

First example / question is the following:
I’m having a rule in which different factors are asked for watering the garden, e.g. temperature above a certain threshold, probability of rain, etc… These are 6 decisions and Id like to know each day why for instance the garden wasnt wartered.

So my idea would be to create an array of only one liners which say for instance:
Temperature too low
Soil Moisture still above threshhold

Therefore I created if sequences in the rule and local vars to save the individual sentences. I’d like to put them together in the Habpanel in a sort of Listed box that I can read them line by line. What is the best approach? I don’t know how to continue currently because I am not able to save an array of strings and display them in the habpanel again -.-

currently I have the following, e.g.:
decision4 = "Too much rain tomorrow. "
decision6 = "Temperature below 5 °C. "

FBWateringText.sendCommand(decision1,decision2,decision3,decision4,decision5)

But I don’t know how to put this into lines later on in the habpanel… any idea?

Thanks a lot in advance, BR
Klim!!

Hi

Just a thought.

Can you write your log lines to a text file and use a template widget with an iframe to show that file in HabPanel?

I’ve seen topics on here that cover such a solution.
(I think they were talking about viewing the standard log files in HabPanel)

There are certainly ways to show standard (non formatted) text files in a webpage.

1 Like

Is there any other idea around? Writing log files and reading them in the habpanel is quite a stretch…?!

Do you want to see the whole log?

Or just 1 entry / statement?

If it’s just the latter, you could just update a String Item in OH and have that displayed in your UI ?

I have a String Item updated with various bits of information to make up a full sentence to display in HabPanel

In a sitemap based UI, you could put these strings into individual text Items, and use visibility feature to hide/show lines with empty content.
I don’t know what the equivalent in habpanel would be.

I would like to show lets say the last 5 things or so… in future I’d like to add warnings and Infos an maybe errors and use it as debug log console, that I know at all times what is going on in my smarthome wrt to rules etc. which I set… the normal log is too overflooded to use it for the purpose of surveillance…

thanks for helping out MDAR! :wink:

Is there any feature which uses the combination of Loginfo in rules and the display in habpanel? That might be pretty useful…

Thanks rossko, I am currently using habpanel only… :confused:

Make five String Items to hold your texts.
Instead of logInfo(), postUpdate your texts to the Items.
You could write particular types of messages to a particular Item.
Or, you could write everything to one special Item and have a rule that shuffles old messages along a Group of Items.

1 Like

I think @rossko57 has the best suggestion.

I managed to get an echo command to append a log file successfully with (replaced) spaces in the strings, even getting a tail -n 10 logging.log command to push the last 10 lines back into another string item.

I even got another rule to strip out my replaced spaces with spaces again.

But…

Habpanel doesn’t seem to support “New Lines” in string, so the whole log just turned into a nasty mess,

So I would say that a simple rule is required.

Push your “decision” into a string item

Then a rule cascades that into a set of 5 items.

IE
Moved all the contents down one.

Item 4 to Item 5
Item 3 to Item 4
Item 2 to Item 3
Item 1 to Item 2

New decision to Item 1



My efforts that failed today, if anyone is interested,

logging.sh script

# Usage :- logging.sh --value=12345

# Output will be a file called logging.log with one line added, containing  today's date and time, value

while [ "$#" -gt 0 ]; do
  case "$1" in
    -v) value="$2"; shift 2;;

    --value=*) value="${1#*=}"; shift 1;;

    --value) echo "$1 requires an argument"
>&2; exit 1;;
    -*) echo "unknown option: $1" >&2; exit 1;;
    *) handle_argument "$1"; shift 1;;
  esac


echo $(date +%F" "%T),$value >> /etc/openhab2/logging.log


done

One OH String item that receives the Log Line
another for the edited tail of the logging.log output.

An EXEC binding thing with a tail command

tail -n 10 /etc/openhab2/logging.log

The output of which is put into a String item for another rule to replace the spaces with
and a switch item attached to the Running channel to fire it when a log line is created.

Two rules

rule "Echo Item to Log"
when 
Item EchoToLogFile_Input changed
then
logInfo("Echo Logging", "\nEcho Logging state = \n"+EchoToLogFile_Input.state)
executeCommandLine("sh /etc/openhab2/logging.sh --value='"+EchoToLogFile_Input.state.toString.replace(" ","%q")+"'",500)
TailLogging_Running.sendCommand(ON)
end



rule "Replace %q in Tail Logging"
when
Item TailLogging_Output changed
then
TailLogging_OutputEdited.sendCommand(TailLogging_Output.state.toString.replace("%q"," "))
end

It’s not an elegant solution, but it does create a text file, that could be pulled into Habpanel using a Template widget.

1 Like

Small detail; do it from the “bottom up” i.e. start with the oldest one you are discarding. The first move above destroys the “old” item 2.

2 Likes

Hey guys, the more I am thinking about this, the more interesting it gets. I thought today that maybe a differentiation as in the log into info, warning and error could be an idea?

This way one could use information in rules for example to show that certain lights switched on or or or. If you issue a warning this might need the users attention, but definitely an error message should be confirmed from the user by e.g. click on a button.

What do you think about this LOG mechanism for the habpanel? I don’t want to dive deep into the log files each day just to make sure certain things happened (or didn’t happen because of failures etc.)…

One could even create a list where all the infos are displayed, that you can scroll through them…?!