Hi All,
I'd like to monitor my traveling time to work with Domoticz. I was thinking of doing that by monitoring the difference between 2 switches:
So difference between:
Time Home = Off
Time Work = On
This must be doable in Lua or something (except I don't know how) but it becomes a bit more complicated because offcourse I won't ALWAYS be heading to work when I leave my house. So I need the script only to start when Work = On, and then take the last "Off" entry from my Home switch.
First I'd just like to put the output in a simple log file, maybe later some kind of graphic.
Any ideas here?
Store time difference between switches in log file
Moderator: leecollings
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Store time difference between switches in log file
In pass2php that would be like this:
pass2php/work.php
That would print a line in the Domoticz logfile with a text like:
2017-03-04 16:33:22 -> Arrived at work, travel time was 1:02:13
Of course the command could easily write to another txt file, MySQL database,... A database would be best option if you like to make statistics on it.
pass2php/work.php
Code: Select all
if($status=='On'){
print strftime("%Y-%m-%d %H:%M:%S",time).' -> Arrived at work, travel time was '.convertToHours(time-apcu_fetch('tHome').PHP_EOL;
}
2017-03-04 16:33:22 -> Arrived at work, travel time was 1:02:13
Of course the command could easily write to another txt file, MySQL database,... A database would be best option if you like to make statistics on it.
Who is online
Users browsing this forum: No registered users and 0 guests