An on/off switch does not have a report available through logs - reports.
I would like to have a report showing the time in a state. So for instance it will indicate that the switch was turned on for 1 hours, and 23 hours it was off for a day. Of course then totals per week, month et cetera
On/off switch report
Moderators: leecollings, remb0
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: On/off switch report
Something like this?
My log history is set to 1 day to keep the SQLite database as small as possible.
I also run a script every hour to remove records from not used devices and non-interest ones.
Still in 1 day there're already 3000 records. You want to keep that for years?
That'll be a huge growing table.
What I do besides this is pushing the switch times to a MySQL database for a few devices I want to monitor.
I do this since December 1st for 7 devices , the table already holds 3734 records.
This shows the on/off times of the last 24 hours.
My log history is set to 1 day to keep the SQLite database as small as possible.
I also run a script every hour to remove records from not used devices and non-interest ones.
Still in 1 day there're already 3000 records. You want to keep that for years?
That'll be a huge growing table.
What I do besides this is pushing the switch times to a MySQL database for a few devices I want to monitor.
I do this since December 1st for 7 devices , the table already holds 3734 records.
Re: On/off switch report
Yes something like that. Yes history keeping might be a next thing, but I would only need the totals to be saved. So if I have a total for a day, and save that it would be good. This would mean 365 values per year for a single device.
How did you construct your output? I am guessing with your Pass2php script, but then?
How did you construct your output? I am guessing with your Pass2php script, but then?
Re: On/off switch report
I now managed this via a LUA script and virtual devices. The script is like this; in this case I did not use the switches as input but rather a state variable. Using switches would be somewhat similar.
Code: Select all
commandArray = {}
function datetimedifferencenow(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
local function DeviceUpdateCounter(name, value1)
local idx = otherdevices_idx[name]
if Debug=='YES' then
print('setting '..name..'; to value '..tostring(value1))
end
local cmd = string.format("%d|%d|%d", idx, value1, value1)
--print(cmd)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
local function UpdateTimeCounter(name)
local deltaSeconds = datetimedifferencenow(uservariables_lastupdate['WPTimestamp'])
local deltaMinutes = deltaSeconds / 60
local previousCount = otherdevices_svalues[name]
-- print('previous count was ' .. previousCount)
DeviceUpdateCounter(name, tonumber(previousCount) + deltaMinutes)
end
-- WP State: 0=init,1=uit,2=CV,3=boiler,4=vrijkoel,5=ontluchten
Debug = 'YES'
local hour = tonumber(os.date("%H"))
local minute = tonumber(os.date("%M"))
if ((minute % 3) == 0) then
local wpState = otherdevices['WP State']
if wpState=='1' then
UpdateTimeCounter('WP Standby Tijd')
elseif wpState=='2' then
UpdateTimeCounter('WP CV Tijd Actief')
elseif wpState=='3' then
UpdateTimeCounter('WP Boiler Tijd Actief')
elseif wpState=='4' then
UpdateTimeCounter('WP Koel Tijd Actief')
end
commandArray['Variable:WPTimestamp']=tostring(os.date("%H:%M"))
end
return commandArray
Who is online
Users browsing this forum: No registered users and 1 guest