Over Domoticz
Version: 4.11605
Build Hash: 7de1f368f
Compile Date: 2020-01-08 23:12:15
dzVents Version: 2.5.5
Python Version: 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.2.0]
Hey
I am looking for a command to reset the text log of a switch / sensor via a script file.
I am looking for the command that is under the delete button (wissen).
Reset automatic Textlog sensors
Moderators: leecollings, remb0
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reset automatic Textlog sensors
Can you try this one ?
read the comments in the script first. If anything is not clear please feel free to ask
Code: Select all
local scriptVar = 'textClearAPI'
return
{
on =
{
devices =
{
'clearText', -- create as a virtual selector type switch. Levels 0 = 'Off',
-- 10, 20, etc.. like clear nameOfDevicetoClear log & text
-- name of the device to clear must be the second word in the level
},
httpResponses =
{
scriptVar,
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = 'Clear text and log: ',
},
execute = function(dz, item)
local function getAndClearLightLog(idx)
local getTextURL = dz.settings['Domoticz url'] .. '/json.htm?type=textlog&idx=' .. idx
local deleteTextURL = dz.settings['Domoticz url'] .. '/json.htm?type=command¶m=clearlightlog&idx=' .. idx
dz.openURL(
{
url = getTextURL,
method = "GET",
callback = scriptVar,
})
dz.openURL(deleteTextURL).afterSec(3)
end
if item.isDevice and item.level ~= 0 then
clearDevice = dz.devices(dz.utils.stringSplit(item.levelName,' ')[2])
dz.log('current text: ' .. clearDevice.state)
if clearDevice.deviceSubType == 'Text' then clearDevice.updateText('').silent() end
getAndClearLightLog(clearDevice.id)
item.switchOff().silent()
elseif item.isHTTPResponse then
for index, record in ipairs( item.json.result) do
dz.log(record.Date .. ' ' .. record.Data)
end
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 38
- Joined: Wednesday 10 January 2018 16:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 38153
- Location: Raalte Holland
- Contact:
Re: Reset automatic Textlog sensors
Waaren tks
I will convert the script.
What matters to me is that the logs of certain sensors are emptied every month.
Or maybe even better, save the last 50 or 100 (adjustable).
And automatically erase the rest.
Thanks in advance for this example.
I will convert the script.
What matters to me is that the logs of certain sensors are emptied every month.
Or maybe even better, save the last 50 or 100 (adjustable).
And automatically erase the rest.
Thanks in advance for this example.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reset automatic Textlog sensors
Is this not already a standard feature of domoticz that can be configured in [setup] [settings] [log history] ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 38
- Joined: Wednesday 10 January 2018 16:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 38153
- Location: Raalte Holland
- Contact:
Re: Reset automatic Textlog sensors
That are all sensors.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reset automatic Textlog sensors
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 38
- Joined: Wednesday 10 January 2018 16:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 38153
- Location: Raalte Holland
- Contact:
Re: Reset automatic Textlog sensors
Hello Waaren
You misunderstand me.
I mean that I want to reset some sensors / switches / lights logs, not all. But only the item I have chosen.
You misunderstand me.
I mean that I want to reset some sensors / switches / lights logs, not all. But only the item I have chosen.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reset automatic Textlog sensors
OK, understand now. Thx for clarifying.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Bing [Bot] and 1 guest