I wrote a script to manage a heater. The script works but I don't understand the logs which don't seem consistent with what script does.
Context: I have a heater managed by zwave device that is registered in domoticz as a Dimmer device ('Rad_SdB') (value <10 means heater is Off, value >=50 means heater is full On). I had created separate dummy devices to manage temporary heating (ie dummy device is of switch type and I set it so that it turns off after XXX seconds after switch on. I can command this dummy devices (such as 'serviettes_SdB') through my google home, using the google plugin, and the script is then modifying the value of Dimmer linked to heater.
Script:
Code: Select all
return {
on = {
devices = {
'Serviettes_SdB'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'script SdB',
},
execute = function(dz, device)
dz.log('Device ' .. device.name .. ' was changed and Rad_Sdb currently at '.. dz.devices('Rad_SdB').level .. ' and switch at ' .. device.state, dz.LOG_INFO)
if (device.name=='Serviettes_SdB' and device.state=='On') then
dz.log('Rad_SdB initially set to '..dz.devices('Rad_SdB').level, dz.LOG_INFO)
dz.devices('Rad_SdB').dimTo(60)
dz.log('Rad_SdB now set to '..dz.devices('Rad_SdB').level, dz.LOG_INFO)
end
if (device.name=='Serviettes_SdB' and (device.state=='Off') ) then
dz.log('Rad_SdB initially set to '..dz.devices('Rad_SdB').level, dz.LOG_INFO)
dz.devices('Rad_SdB').dimTo(1)
dz.log('Rad_SdB set to '..dz.devices('Rad_SdB').level, dz.LOG_INFO)
end
end
}
and the logs when switching off:2024-03-10 21:33:29.810 Serviettes_SdB: Light/Switch (Serviettes_SdB)
2024-03-10 21:33:29.975 Zstick Gen5: Domoticz has send a Switch command!, Level: 60, NodeID: 31 (0x1f)
2024-03-10 21:33:29.983 Zstick Gen5: Light/Switch (Rad_SdB)
2024-03-10 21:33:29.788 Status: User: eric (IP: 192.168.0.254) initiated a switch command (2604/Serviettes_SdB/On)
2024-03-10 21:33:29.931 Status: dzVents: Info: Handling events for: "Serviettes_SdB", value: "On"
2024-03-10 21:33:29.931 Status: dzVents: Info: script SdB: ------ Start internal script: Radiateur_SdB: Device: "Serviettes_SdB (Serviettes_SdB)", Index: 2604
2024-03-10 21:33:29.932 Status: dzVents: Info: script SdB: Device Serviettes_SdB was changed and Rad_Sdb currently at 1 and switch at On
2024-03-10 21:33:29.932 Status: dzVents: Info: script SdB: Rad_SdB initially set to 1
2024-03-10 21:33:29.933 Status: dzVents: Info: script SdB: Rad_SdB now set to 1
2024-03-10 21:33:29.933 Status: dzVents: Info: script SdB: ------ Finished Radiateur_SdB
2024-03-10 21:33:29.935 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
As you can see, the proper command is sent to the heater dimmer device (2d row above when switching on, set to 60 level), but the logs show wrong values ("1"): I would expect to read "initially set to 1" and "now set to 60" when switching on). Same issue (in opposite way) when switching off.2024-03-10 21:36:09.970 Serviettes_SdB: Light/Switch (Serviettes_SdB)
2024-03-10 21:36:09.955 Status: User: eric (IP: 192.168.0.254) initiated a switch command (2604/Serviettes_SdB/Off)
2024-03-10 21:36:10.114 Zstick Gen5: Domoticz has send a Switch command!, Level: 1, NodeID: 31 (0x1f)
2024-03-10 21:36:10.122 Zstick Gen5: Light/Switch (Rad_SdB)
2024-03-10 21:36:10.088 Status: dzVents: Info: Handling events for: "Serviettes_SdB", value: "Off"
2024-03-10 21:36:10.089 Status: dzVents: Info: script SdB: ------ Start internal script: Radiateur_SdB: Device: "Serviettes_SdB (Serviettes_SdB)", Index: 2604
2024-03-10 21:36:10.090 Status: dzVents: Info: script SdB: Device Serviettes_SdB was changed and Rad_Sdb currently at 60 and switch at Off
2024-03-10 21:36:10.090 Status: dzVents: Info: script SdB: Rad_SdB initially set to 60
2024-03-10 21:36:10.090 Status: dzVents: Info: script SdB: Rad_SdB set to 60
2024-03-10 21:36:10.090 Status: dzVents: Info: script SdB: ------ Finished Radiateur_SdB
I probably don't understand something here.. Anyone could help me ?
note: I use domoticz v2023.2 on Raspbian
br,
Ricorico94