Page 1 of 2
Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 18:47
by sailmich
I have had a dzvents code running to switch my thermostats when a significant drop of temperature happening. All is running well since one or two updates of domoticz version ago. Today I recognized that the thermostat mode was always Heat even when window is open. To check if something wrong with my thermostats I used a dummy switch 'Test'
- Spoiler: show
- return {
on = {
devices = {
'Test'
}
},
execute = function(domoticz, device)
if domoticz.devices('Test')=='On' then
domoticz.devices('Thermostat Mode').updateMode('Heat')
elseif domoticz.devices('Test')=='Off' then
domoticz.devices('Thermostat Mode').updateMode('Off')
end
end
In my domoticz log I got
2019-01-07 18:42:41.611 Status: dzVents: Info: Handling events for: "Test", value: "On"
2019-01-07 18:42:41.612 Status: dzVents: Info: ------ Start internal script: TestHeizungSchalten: Device: "Test (Dummys)", Index: 324
2019-01-07 18:42:41.612 Status: dzVents: Info: ------ Finished TestHeizungSchalten
Am I doing something wrong or is there a problem with dzvents?
In domoticz utilities I can change the thermostat mode and the mode is really changing on the thermostat!
Thx for any hint
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 19:46
by waaren
sailmich wrote: ↑Monday 07 January 2019 18:47
Today I recognized that the thermostat mode was always Heat even when window is open. To check if something wrong with my thermostats I used a dummy switch 'Test'
Can you execute this script ? This might give some extra information.
Code: Select all
return {
on = { devices = { 'Test' }},
execute = function(domoticz, device)
local thermostat = domoticz.devices('Thermostat Mode')
local modes = thermostat.modes
local mode = thermostat.mode
local modeString = thermostat.modeString
local allModes = "\n\n"
for i,v in ipairs(modes) do
allModes = allModes .. i .. " " .. v .. "\n"
end
domoticz.log("Thermostat mode string: " .. modeString,domoticz.LOG_FORCE)
domoticz.log("Thermostat mode number: " .. mode,domoticz.LOG_FORCE)
domoticz.log("Thermostat possible modes: " .. allModes,domoticz.LOG_FORCE)
end
}
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 20:09
by sailmich
This it what I got in domoticz log.
Script #1 is copy and paste your code.
2019-01-07 20:06:01.865 Status: dzVents: Debug: Event triggers:
2019-01-07 20:06:01.865 Status: dzVents: Debug: - Device: Test
2019-01-07 20:06:01.664 Error: EventSystem: Lua script Script #1 did not return a commandArray
2019-01-07 20:06:02.047 Error: EventSystem: Lua script Script #1 did not return a commandArray
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 21:28
by waaren
sailmich wrote: ↑Monday 07 January 2019 20:09
This it what I got in domoticz log.
Script #1 is copy and paste your code.
2019-01-07 20:06:01.865 Status: dzVents: Debug: Event triggers:
2019-01-07 20:06:01.865 Status: dzVents: Debug: - Device: Test
2019-01-07 20:06:01.664 Error: EventSystem: Lua script Script #1 did not return a commandArray
2019-01-07 20:06:02.047 Error: EventSystem: Lua script Script #1 did not return a commandArray
It looks like you saved it as a Lua script. You should save it as a dzVents script.
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 22:06
by sailmich

I didn't realized that.
- Spoiler: show
- 2019-01-07 21:45:02.059 Status: User: Admin initiated a switch command (324/Test/On)
2019-01-07 21:45:02.164 Status: dzVents: Debug: Dumping domoticz data to /home/pi/domoticz/scripts/dzVents/domoticzData.lua
2019-01-07 21:45:02.298 Status: dzVents: Debug: Processing device-adapter for Test: Switch device adapter
2019-01-07 21:45:02.299 Status: dzVents: Debug: dzVents version: 2.4.9
2019-01-07 21:45:02.299 Status: dzVents: Debug: Event triggers:
2019-01-07 21:45:02.299 Status: dzVents: Debug: - Device: Test
2019-01-07 21:45:02.340 Status: dzVents: Info: Handling events for: "Test", value: "On"
2019-01-07 21:45:02.340 Status: dzVents: Info: ------ Start internal script: Script #1: Device: "Test (Dummys)", Index: 324
2019-01-07 21:45:02.344 Status: dzVents: Debug: Processing device-adapter for Thermostat Mode: Z-Wave Thermostat mode device adapter
2019-01-07 21:45:02.344 Status: dzVents: !Info: Thermostat mode string: Heat
2019-01-07 21:45:02.344 Status: dzVents: !Info: Thermostat mode number: 1
2019-01-07 21:45:02.344 Status: dzVents: !Info: Thermostat possible modes:
2019-01-07 21:45:02.344
2019-01-07 21:45:02.344 1 Off
2019-01-07 21:45:02.344 2 Heat
2019-01-07 21:45:02.344 3 Heat Eco
2019-01-07 21:45:02.344 4 Full Power
2019-01-07 21:45:02.344 5 Manufacturer Specific
2019-01-07 21:45:02.344
2019-01-07 21:45:02.344 Status: dzVents: Info: ------ Finished Script #1
I might have make a mistake during copy and paste and saved as at lua instead of dzvents. Now I saved my script new as dzvents and I can find it under dzVents/generated_scripts so should work again.
Thank to spent your time! Next time I will check it before post as a problem.
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 07 January 2019 23:19
by waaren
sailmich wrote: ↑Monday 07 January 2019 22:06
Now I saved my script new as dzvents and I can find it under dzVents/generated_scripts so should work again.
Thank to spent your time! Next time I will check it before post as a problem.
Leaving the question why the Thermostat is not updated. We see that Off is one of the possible modes. But it does not seem to work ?
I had a look at the device-adapter in dzVents and do see something strange but do not know for sure if it is a bug. i don't own this device so hopefully you can test (if the problem is still there )?
Can you change in file
domoticz\dzVents\runtime\device-adapters\zwave_thermostat_mode_device.lua
line 45 from
to
and test again ?
It might help you and others and if not, we at least tried and tested and can be reverted without any problem.
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 4:50
by sailmich
I can't see any different in log.
- Spoiler: show
- 2019-01-08 04:44:14.244 Status: dzVents: Info: ------ Start internal script: Script #1: Device: "Test (Dummys)", Index: 324
2019-01-08 04:44:14.248 Status: dzVents: Debug: Processing device-adapter for Thermostat Mode: Z-Wave Thermostat mode device adapter
2019-01-08 04:44:14.248 Status: dzVents: !Info: Thermostat mode string: Heat
2019-01-08 04:44:14.248 Status: dzVents: !Info: Thermostat mode number: 1
2019-01-08 04:44:14.248 Status: dzVents: !Info: Thermostat possible modes:
2019-01-08 04:44:14.248
2019-01-08 04:44:14.248 1 Off
2019-01-08 04:44:14.248 2 Heat
2019-01-08 04:44:14.248 3 Heat Eco
2019-01-08 04:44:14.248 4 Full Power
2019-01-08 04:44:14.248 5 Manufacturer Specific
2019-01-08 04:44:14.248
2019-01-08 04:44:14.249 Status: dzVents: Info: ------ Finished Script #1
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 6:28
by sailmich
My window open script doesen't work this morning.
Code: Select all
return {
on = {
timer = {'every 5 minutes'}[attachment=0]Bildschirmfoto vom 2019-01-08 06-14-39.png[/attachment]
},
data = {
previousTemperature1 = { initial = 100 }
},
execute = function(domoticz)
local schlafzimmerSensor = domoticz.devices('Schlafzimmer')
--Schlafzimmer
if (domoticz.data.previousTemperature1 - schlafzimmerSensor.temperature) >= 0.3 and domoticz.devices('Thermostat Mode Schlafzimmer').state == Heat then
-- Window is open there was a significant drop
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Off')
domoticz.devices('Lüften').switchOn() -- Use as a log
elseif (domoticz.data.previousTemperature1 - schlafzimmerSensor.temperature) < 0.2 and domoticz.devices('Thermostat Mode Schlafzimmer').state == Off then
domoticz.devices('Lüften').switchOff()
-- Window is closed
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Heat')
end
-- store current value for next cycle
domoticz.data.previousTemperature1 = schlafzimmerSensor.temperature
end
Between 5:55 and 6:00 temperature droped 0.4°C so should set thermostat to Off. But doesn't.
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 11:05
by waaren
sailmich wrote: ↑Tuesday 08 January 2019 4:50
I can't see any different in log.
No the proposed change is for the actual update. My script only displays the status and the options.
So please test with my proposed change and see if the update (your script) works.
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 11:10
by sailmich
No it doesn't work.
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 11:27
by waaren
sailmich wrote: ↑Tuesday 08 January 2019 11:10
No it doesn't work.
Shouldn't there be quotes around Heat and Off ? Please try script below with both versions of the device-adapter. Thx
Code: Select all
return {
on = { timer = {'every 5 minutes'}},
data = { previousTemperature1 = { initial = 100 }},
execute = function(domoticz)
local schlafzimmerSensor = domoticz.devices('Schlafzimmer')
--Schlafzimmer
if (domoticz.data.previousTemperature1 - schlafzimmerSensor.temperature) >= 0.3 and domoticz.devices('Thermostat Mode Schlafzimmer').state == 'Heat' then
-- Window is open there was a significant drop
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Off')
domoticz.devices('Lüften').switchOn() -- Use as a log
elseif (domoticz.data.previousTemperature1 - schlafzimmerSensor.temperature) < 0.2 and domoticz.devices('Thermostat Mode Schlafzimmer').state == 'Off' then
domoticz.devices('Lüften').switchOff()
-- Window is closed
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Heat')
end
-- store current value for next cycle
domoticz.data.previousTemperature1 = schlafzimmerSensor.temperature
end
}
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 14:23
by sailmich
Of course you are right quotes are necessary, happened because of all my tries

. But also with quotes it doesn't work.
To test I use a dummy switch as a trigger.This work
- Spoiler: show
-
Code: Select all
return {
on = {
devices = {'Lüften'}
},
execute = function(domoticz, device)
if domoticz.devices('Lüften').state == 'On' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Off')
elseif domoticz.devices('Lüften').state == 'Off' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Heat')
end
end
}
This doesn't work
- Spoiler: show
Code: Select all
return {
on = {
devices = {'Lüften'}
},
execute = function(domoticz, device)
if domoticz.devices('Lüften').state == 'On' and domoticz.devices('Thermostat Mode Schlafzimmer').state == 'Heat' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Off')
elseif domoticz.devices('Lüften').state == 'Off' and domoticz.devices('Thermostat Mode Schlafzimmer').state == 'Off' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Heat')
end
end
}
So something wrong with second part of if statement.
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 17:24
by waaren
sailmich wrote: ↑Tuesday 08 January 2019 14:23
So something wrong with second part of if statement.
Is your first script succesfull with the modified domoticz\dzVents\runtime\device-adapters\zwave_thermostat_mode_device.lua or with the original ?
I guess you should change the attribute "state" to "modeString" in the 2nd script for the Thermostate device like
Code: Select all
return {
on = {
devices = {'Lüften'}
},
execute = function(domoticz, device)
if domoticz.devices('Lüften').state == 'On' and domoticz.devices('Thermostat Mode Schlafzimmer').modeString == 'Heat' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Off')
elseif domoticz.devices('Lüften').state == 'Off' and domoticz.devices('Thermostat Mode Schlafzimmer').modeString == 'Off' then
domoticz.devices('Thermostat Mode Schlafzimmer').updateMode('Heat')
end
end
}
Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 18:57
by sailmich
waaren wrote: ↑Tuesday 08 January 2019 17:24
Is your first script succesfull with the modified domoticz\dzVents\runtime\device-adapters\zwave_thermostat_mode_device.lua or with the original ?
With booth! With mode I got Heat and Off in the log, with i I got 1 and 0. Booth switch the mode from Heat to Off and vice versa.
waaren wrote: ↑Tuesday 08 January 2019 17:24
I guess you should change the attribute "state" to "modeString" in the 2nd script for the Thermostate device like
You are my hero! That did the trick. I didn't try that. Examples in documentation of dzVents would be fine for idiots like me

Re: Thermostat Mode doesn't work anylonger?
Posted: Tuesday 08 January 2019 20:24
by waaren
sailmich wrote: ↑Tuesday 08 January 2019 18:57
Examples in documentation of dzVents would be fine for idiots like me
Not with an example but it's definitely in
the wiki 
Re: Thermostat Mode doesn't work anylonger? [SOLVED]
Posted: Tuesday 08 January 2019 20:42
by sailmich
I also saw it but I'm not clever enough to anticipate and use it.
Thanks again I learned a lot!
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 08 March 2021 21:39
by zanna1972
Hi, do you know how to change the thermostat mode using json api?
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 08 March 2021 21:46
by waaren
zanna1972 wrote: ↑Monday 08 March 2021 21:39
Hi, do you know how to change the thermostat mode using json api?
There are different types of thermostats What is the type and subtype of the thermostat as seen on the devices tab?
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 08 March 2021 21:48
by zanna1972
Type=General
Subtype=thermostat mode
Re: Thermostat Mode doesn't work anylonger?
Posted: Monday 08 March 2021 22:01
by waaren
zanna1972 wrote: ↑Monday 08 March 2021 21:48
Type=General
Subtype=thermostat mode
Can you run below script to identify the details of this device?
It might help to find the right API call for it.
Code: Select all
return
{
on =
{
timer =
{
'at 17:32', -- change to the time you want to dump the attributes of the device
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'dumpAttributes',
},
execute = function(dz)
local myDevice = dz.devices(1656) -- your device idx
-- if you don't have sqlite3 yet on your system install it with sudo apt install sqlite3
local sqlite = '/usr/local/bin/sqlite3' -- find your sqlite3 location with "which sqlite3" and change here accordingl
local function dumpAttributes(dv)
dz.log(dv.idx .. ': ' .. dv.name .. ': attribute -> value',dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': -- dzVents',dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': type, subType -> ' .. dv.deviceType .. ', '.. tostring(dv.deviceSubType),dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': switchTypeValue -> ' .. dv.switchTypeValue ,dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': adapters -> ' .. dz.utils._.str(dv._adapters),dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': rawData -> ' .. dz.utils._.str(dv.rawData),dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': hwType -> ' .. dv.hardwareType .. ', ' .. dv.hardwareTypeValue,dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': levelNames -> ' .. dz.utils._.str(dv.levelNames),dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': modes -> ' .. dz.utils._.str(dv.modes),dz.LOG_FORCE)
end
local function dumpDeviceStatus(dv)
local sqlResult, result = dz.utils.osCommand('sudo ' .. sqlite .. ' ' .. '-header domoticz.db "select * from deviceStatus where id = ' .. dv.idx .. '"')
if result ~= 0 then
dz.log('Result: ' .. result, dz.LOG_ERROR)
else
sqlResult = dz.utils.stringSplit(sqlResult,'\n')
local header = dz.utils.stringSplit(sqlResult[1],'|')
local values = dz.utils.stringSplit(sqlResult[2],'|')
dz.log(dv.idx .. ': ' .. dv.name .. ': field -> value',dz.LOG_FORCE)
dz.log(dv.idx .. ': ' .. dv.name .. ': -- database',dz.LOG_FORCE)
for index, attribute in ipairs(header) do
dz.log(dv.idx .. ': ' .. dv.name .. ': ' .. dz.utils.rightPad(( attribute or '') ,15) .. ' -> ' .. ( values[index] or 'nil') ,dz.LOG_FORCE)
end
end
end
dumpAttributes(myDevice)
dz.log('',dz.LOG_FORCE)
dumpDeviceStatus(myDevice)
end
}