Display total usage of a device between one on and off period

Hi!

Is it possible to view log files in openhab2 basic ui? I found some solution but, not any working.
Is it possible to watch some exact action, like somebody when turn on the light switch?
I setup my system, to send push message, but I want to log the time.

Thanks, and sorry for my english!

Have a look at the log reader binding - https://www.openhab.org/addons/bindings/logreader/

I only found this yesterday and started using it.

It has examples for notification with telegram. You could use customEvent to look for turning on the light swtich.

But, in that example - turning on a light switch, I think creating a rule:

rule "Light Notification"
when
    light_switch changed to ON
then
   some_notification_option.postUpdate("Light Switch has turned on")
end

Sorry this is not real code for the notification as I don’t know what commands they should use, but would be better than reading the log.

Hi!

I tried the logreader bindig, but it is’t worked for me.
You are right about the rule solution, but how can I write the state change to a file, and how can I view it on basic ui?

Install and configure Frontail (if you are using openHABian it’s already installed and configured). Use a Webview element to display the web page that Frontail provides.

Beyond that the answer is you can’t. You can have String Items showing one line of text. If that is sufficient, than the Log Reader binding can be used to change that Item with a new value when ever a log entry of interest occurs.

All state changes are already written out to a file, events.log. But you can’t view it in BasicUI except by importing some other webpage that shows it.

Hi!

I’m a biginner, can you post some code examples?

Thanks!

Not really as I don’t do anything like this and your end goal is unclear. Why would you want to do this in the first place? BasicUI is the user interface you create to give to the users of your home. Your family members and guests are not going to want to see nor be able to use a bunch of scrolling by log entries. And it will be scrolling by probably just fast enough to make it impossible to read anyway given how little room there is to present any information on BasicUI anyway.

So do you just want this for yourself? Are you using openHABian? If so it’s probably already installed so just select Frontail when you bring up http://openhabian:8080. If not installed, run openhabian-config and install it. If not using openHABian, see https://github.com/mthenw/frontail for instructions for installing and configuring it. Then open Frontail in a separate browser window to watch the logs.

Do you care about specific events? See psyciknz’s reply above to either send an alert or update an Item’s state when that event occurs.

Want to see in a graph when a door was open or closed, see InfluxDB+Grafana persistence and graphing.

You have to explain why you want to do this. What do you want to achieve.

With the information provided, this looks very much like an XY Problem coupled with “when the only tool I have is a hammer all problems look like nails.” Explain what you end goal is and we can probably tell you the best way to achieve it. But it almost certainly will not be by adding a view of your logs scrolling by to BasicUI.

I use Raspberry Pi with openHAB2, not openHabian.
I want to know when my boy turn on his PS4, and when turn it off. Now I have a push notification, openHAB cloud sends me a push massege when he turn it on, and off. I like to see it in a log file, with time flag, under basic ui.

Here is where you have the XY Problem. Why does it have to be a log file? Why not a database? Do you want to only see the last time it was turned on or off on the sitemap or all the entries for the last 24 hour hours or just for the current day? Do you want just a list or something like

Ultimately, what you are specifically asking for is not possible. But the information you want to display in BasicUI is absolutely possible, just not using the approach you want.

Your solution is great, how can I do that?

Thanks!

The myopenhab log info is perfet for me, is that possible to show it in basic ui?

Which one? The chart? Look at the links I posted in reply 6, in particular the link that has InfluxDB+Grafana in the name.

Again, you can show any external web page in BasicUI using the Webview element (linked to the docs above. But you don’t have a lot of room so that page most likely will not be usable.

Yes, the chart. Thanks, I will try.

Webview element not a good solution, because each time when I check the notification, must login with username and password.

My goal is to display total usage of a device between one on and off period - basically need to know for how long this device was switched on. I’am wathing the device IP, if ping returns it’s on.

I found this topics, similar problem with mine, but I could not adapt the code, would somebody help me?

Thanks!