How to change thermostat operating state  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

How to change thermostat operating state

Post by sailmich »

I'm on leatest beta /RPI 3/Zstick
I have a zwave MCOEMH7-EH2 wall thermostat. I would like to get it more accurate by reduce the hysteresis from 0,5 to 0,2 by control it in zwave. I try to change the thermostat operating state but can't find the correct command.
Spoiler: show

Code: Select all

-- Temperature measure = IDX 354
-- Temperature setpoint = IDX 347
-- Thermostat Operating State = IDX 349
return {
	on = {
		timer = {'every minute'},
		
	},
	data = {},
	logging = {},
	execute = function(dz, triggeredItem)
	  local tempSensor = dz.devices(354).temperature
	        tempSetPoint = dz.devices(347).setPoint
	        
    if (tempSensor-tempSetPoint) < 0.1 and (tempSetPoint-tempSensor) < 0.1 and dz.devices(349).state == '2' then
    --dz.devices(349).updateMode(0)
    --dz.devices(349).updateMode('Idle')
    --dz.devices(349).setPoint(0)
    --dz.devices(349).setPoint = 0
    --dz.devices(349).setPoint = '0'
    dz.devices(349).heatingMode('0')
	end
end
}

If statement is working but update the state doesn't :(
Any help appreciated!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Sunday 29 November 2020 20:51 If statement is working but update the state doesn't :(
Not sure it that's possible but to be able to try something, we first have to understand the characteristics / attributes of the device. Can you therefore execute below script and post the result?

Code: Select all

return
{
    on =
    {
        timer =
        {
            'at 17:51', -- 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(349)

        local function dumpAttributes(dv)
            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

       dumpAttributes(myDevice)

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

Here the result.
20-11-30 07:04:00.474 Status: dzVents: Info: dumpAttributes: ------ Start internal script: Script #3:, trigger: "at 07:04"
2020-11-30 07:04:00.509 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : type, subType -> General, Thermostat Operating State
2020-11-30 07:04:00.509 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : switchTypeValue -> 0
2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : adapters -> {}
2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : rawData -> {}
2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : hwType -> OpenZWave USB, 21
2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : levelNames -> nil
2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : modes -> nil
2020-11-30 07:04:00.510 Status: dzVents: Info: dumpAttributes: ------ Finished Script #3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Monday 30 November 2020 7:10

Code: Select all

2020-11-30 07:04:00.510 Status: dzVents: !Info: dumpAttributes: 349:Thermostat Operating State : adapters -> {}
Thx, this shows the device type is not recognized yet by dzVents. How do you update the state of the device in the GUI ?

Can you also run this script? It might help in creating a dzVents device-adapter for the device type.

Code: Select all

return
{
    on =
    {
        timer =
        {
            'at 09:36', -- 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(349)         -- your device idx
        local sqlite = '/usr/local/bin/sqlite3'  -- find your sqlite3 location with "which sqlite3" and change here accordingly

        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 = dz.utils.osCommand(sqlite .. ' ' .. '-header domoticz.db "select * from deviceStatus where id = ' .. dv.idx .. '"')
            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

        dumpAttributes(myDevice)
            dz.log('',dz.LOG_FORCE)
        dumpDeviceStatus(myDevice)
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

The state is only shown in domoticz. It changes the state when a set point plus hysteresis is reached. I will run your next script when back home from work.
Thx
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

Here it is.

Code: Select all

2020-11-30 16:22:00.755 Status: dzVents: Info: dumpAttributes: ------ Start internal script: Script #4:, trigger: "at 16:22"
2020-11-30 16:22:00.788 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: attribute -> value
2020-11-30 16:22:00.788 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: -- dzVents
2020-11-30 16:22:00.788 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: type, subType -> General, Thermostat Operating State
2020-11-30 16:22:00.788 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: switchTypeValue -> 0
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: adapters -> {}
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: rawData -> {}
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: hwType -> OpenZWave USB, 21
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: levelNames -> nil
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: modes -> nil
2020-11-30 16:22:00.789 Status: dzVents: !Info: dumpAttributes:
2020-11-30 16:22:00.827 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: field -> value
2020-11-30 16:22:00.828 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: -- database
2020-11-30 16:22:00.828 Status: dzVents: Info: dumpAttributes: ------ Finished Script #4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Monday 30 November 2020 16:30 Here it is.
It looks like sqlite3 cannot be found on your system or the database is in a different location. I expect something like

Code: Select all

2020-11-30 10:48:00.074  Status: dzVents: Debug: dumpAttributes: Processing device-adapter for database size: Custom sensor device adapter
2020-11-30 10:48:00.074  Status: dzVents: !Info: dumpAttributes: -- dzVents attributes
2020-11-30 10:48:00.074  Status: dzVents: !Info: dumpAttributes: 730: database size: type, subType   -> General, Custom Sensor
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: adapters        -> {"Custom sensor device adapter"}
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: hwType          -> Dummy (Does nothing, use for virtual switc                             hes only), 15
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: levelNames      -> nil
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: modes           -> nil
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: rawData         -> {"20628"}
2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: 730: database size: switchTypeValue -> 0

2020-11-30 10:48:00.075  Status: dzVents: !Info: dumpAttributes: -- Database attributes
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: AddjMulti       -> 1.0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: AddjMulti2      -> 1.0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: AddjValue       -> 0.0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: AddjValue2      -> 0.0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: BatteryLevel    -> 255
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Color           -> nil
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: CustomImage     -> nil
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Description     -> nil
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: DeviceID        -> 00082730
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Favorite        -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: HardwareID      -> 3
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: ID              -> 730
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: LastLevel       -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: LastUpdate      -> 2020-11-30 10:13:00
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Name            -> database size
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: nValue          -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Options         -> nil
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Order           -> 725
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Protected       -> 1;Kilobyte
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: SignalLevel     -> 12
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: StrParam1       -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: StrParam2       -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: SubType         -> 31
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: sValue          -> 20628
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: SwitchType      -> 0
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Type            -> 243
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Unit            -> 1
2020-11-30 10:48:00.081  Status: dzVents: !Info: dumpAttributes: 730: database size: Used            -> 1
2020-11-30 10:48:00.082  Status: dzVents: Info: dumpAttributes: ------ Finished dz 20201130 dumpAttributes
This modified version will use sudo to access the database and will show a returncode if not equal to 0

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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

020-11-30 18:18:00.561 Status: dzVents: Debug: - Timer
2020-11-30 18:18:00.676 Status: dzVents: Info: dumpAttributes: ------ Start internal script: Script #4:, trigger: "at 18:18"
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: attribute -> value
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: -- dzVents
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: type, subType -> General, Thermostat Operating State
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: switchTypeValue -> 0
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: adapters -> {}
2020-11-30 18:18:00.711 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: rawData -> {}
2020-11-30 18:18:00.712 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: hwType -> OpenZWave USB, 21
2020-11-30 18:18:00.712 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: levelNames -> nil
2020-11-30 18:18:00.712 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: modes -> nil
2020-11-30 18:18:00.712 Status: dzVents: !Info: dumpAttributes:
2020-11-30 18:18:00.803 Status: dzVents: Info: dumpAttributes: ------ Finished Script #4
2020-11-30 18:18:00.803 Status: dzVents: Info: ------ Start internal script: Sonne Süd:, trigger: "at 08:45-20:00"
2020-11-30 18:18:00.808 Status: dzVents: Debug: Processing device-adapter for Wetterstation LUX: Lux device adapter
2020-11-30 18:18:00.810 Status: dzVents: Debug: Processing device-adapter for WetterAußen: Temperature device adapter
2020-11-30 18:18:00.813 Status: dzVents: Debug: Processing device-adapter for WetterInnen: Temperature device adapter
2020-11-30 18:18:00.815 Status: dzVents: Info: ------ Finished Sonne Süd
2020-11-30 18:18:00.815 Status: dzVents: Info: ------ Start internal script: Sonne West:, trigger: "at 11:00-20:00"
2020-11-30 18:18:00.819 Status: dzVents: Info: ------ Finished Sonne West
2020-11-30 18:18:00.822 Status: dzVents: Debug: Commands sent to Domoticz:
2020-11-30 18:18:00.822 Status: dzVents: Debug: - OpenURL = {["URL"]="http://192.xxxxxxx/current.xml", ["method"]="GET", ["_trigger"]="getXML"}
2020-11-30 18:18:00.822 Status: dzVents: Debug: =====================================================
2020-11-30 18:18:00.824 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-30 18:18:00.803 Error: dzVents: Error: (3.0.16) dumpAttributes: Result: 1
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Monday 30 November 2020 18:13 2020-11-30 18:18:00.803 Error: dzVents: Error: (3.0.16) dumpAttributes: Result: 1
Result: 1 shows that the sqlite3 command failed. If it is not too much to ask maybe you can elaborate a bit on what you experienced when searching for the location of sqlite3
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

I tried in /home/pi/domoticz command line: sqlite3 and got "bash: sqlite3: command not found"
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Monday 30 November 2020 18:40 I tried in /home/pi/domoticz command line: sqlite3 and got "bash: sqlite3: command not found"
Did you read this? (in the code I posted)

-- 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

waaren wrote: Monday 30 November 2020 18:46
sailmich wrote: Monday 30 November 2020 18:40 I tried in /home/pi/domoticz command line: sqlite3 and got "bash: sqlite3: command not found"
Did you read this? (in the code I posted)

-- 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
Yes I did. I have three domoticz server up and running, none of them has sqlite3 on :( so I'm puzzled. Should it be on by default? Now I installed sqlite3 it was in /usr/bin and I moved it to /usr/local/bin but same result as before. Even after reboot.
.
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

I moved sqlite3 back were it was and changed your script to /usr/bin/sqlite3. I read your script but didn't realized your comment really sorry for that!
-30 20:06:00.449 Status: dzVents: Debug: - Timer
2020-11-30 20:06:00.546 Status: dzVents: Info: dumpAttributes: ------ Start internal script: Script #4:, trigger: "at 20:06"
2020-11-30 20:06:00.577 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: attribute -> value
2020-11-30 20:06:00.577 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: -- dzVents
2020-11-30 20:06:00.577 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: type, subType -> General, Thermostat Operating State
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: switchTypeValue -> 0
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: adapters -> {}
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: rawData -> {}
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: hwType -> OpenZWave USB, 21
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: levelNames -> nil
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: modes -> nil
2020-11-30 20:06:00.578 Status: dzVents: !Info: dumpAttributes:
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: field -> value
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: -- database
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: ID -> 349
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: HardwareID -> 2
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: DeviceID -> 00005701
2020-11-30 20:06:00.630 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Unit -> 1
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Name -> Thermostat Operating State
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Used -> 1
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Type -> 243
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: SubType -> 35
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: SwitchType -> 0
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Favorite -> 0
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: SignalLevel -> 12
2020-11-30 20:06:00.631 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: BatteryLevel -> 255
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: nValue -> 0
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: sValue -> 2020-11-30 19:40:27
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: LastUpdate -> 349
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Order -> 0.0
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: AddjValue -> 1.0
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: AddjMulti -> 0.0
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: AddjValue2 -> 1.0
2020-11-30 20:06:00.632 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: AddjMulti2 -> 0
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: StrParam1 -> 0
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: StrParam2 -> 0
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: LastLevel -> nil
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Protected -> nil
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: CustomImage -> nil
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Description -> nil
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Options -> nil
2020-11-30 20:06:00.633 Status: dzVents: !Info: dumpAttributes: 349: Thermostat Operating State: Color -> nil
2020-11-30 20:06:00.634 Status: dzVents: Info: dumpAttributes: ------ Finished Script #4
Thank you very much for spending your time! I can understand if you will stop your support for stupid/lazy or not focused guys like me! For me all this linux stuff is still magic. Sorry if I was rude to you!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Monday 30 November 2020 20:23 I moved sqlite3 back were it was and changed your script to /usr/bin/sqlite3. I read your script but didn't realized your comment really sorry for that!
No problem. I now should have enough information from domoticz to start but I hope to find something on the internet on what commands are needed to change the state of this device. I will come back when I find something ( or for more questions :) )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to change thermostat operating state

Post by waaren »

sailmich wrote: Sunday 29 November 2020 20:51 I have a zwave MCOEMH7-EH2 wall thermostat. I would like to get it more accurate by reduce the hysteresis from 0,5 to 0,2 by control it in zwave. I try to change the thermostat operating state but can't find the correct command.
Can you check this?

Code: Select all

--[[
            script to control mode of deviceType: General, device subType: Thermostat Operating State

            Type -> 243
            SubType -> 35
            SwitchType -> 0

]]

local temperatureSensor = 354
local setpoint = 347
local operatingState = 349

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
        marker = 'Thermostat operating state',
    },

    execute = function(dz)

        local temperature = dz.devices(temperatureSensor).temperature
        local setpoint = dz.devices(setpoint).setPoint
        local operatingState = dz.devices(operatingState)
        local mode = operatingState.nValue
        local hysteresis = 0.1
        local modes =
        {
            idle = 0,
            cooling = 1,
            heating = 2,
        }

        local function mode2Text(mode)
            for key, n in pairs(modes) do
                if mode == n then return key end
            end
        end

        local function updateMode(newMode)
            if modes[newMode] ~= mode then
                dz.log('Switching mode from ' .. mode2Text(mode) ..  ' to '  .. newMode,dz.LOG_DEBUG )
                operatingState.update(modes[newMode])
            else
                dz.log('No mode change required',dz.LOG_DEBUG )
            end
        end

        --main
        dz.log('temperature: ' .. temperature ..', setpoint: ' .. setpoint ..', mode: ' .. mode2Text(mode),dz.LOG_DEBUG )
        if ( temperature - setpoint ) > hysteresis then -- heating required
            updateMode('heating')
        elseif ( setpoint - temperature ) > hysteresis then -- cooling required
            updateMode('cooling' )
        elseif mode ~= IDLE then
            updateMode('idle')
        else
            dz.log('No mode change required',dz.LOG_DEBUG )
        end

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state

Post by sailmich »

Thank you very much! I had to change a little bit but now it seems that is working! Cooling isn't necessary because it just open or close a valve so I removed and changed that. Thx again for spending your time to help others! Specially me :lol:

Code: Select all

--[[
            script to control mode of deviceType: General, device subType: Thermostat Operating State

            Type -> 243
            SubType -> 35
            SwitchType -> 0

]]

local temperatureSensor = 354
local setpoint = 347
local operatingState = 349

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
        marker = 'Thermostat operating state',
    },

    execute = function(dz)

        local temperature = dz.devices(temperatureSensor).temperature
        local setpoint = dz.devices(setpoint).setPoint
        local operatingState = dz.devices(operatingState)
        local mode = operatingState.nValue
        local hysteresis = 0.1
        local modes =
        {
            idle = 0,
            heating = 2,
        }

        local function mode2Text(mode)
            for key, n in pairs(modes) do
                if mode == n then return key end
            end
        end

        local function updateMode(newMode)
            if modes[newMode] ~= mode then
                dz.log('Switching mode from ' .. mode2Text(mode) ..  ' to '  .. newMode,dz.LOG_DEBUG )
                operatingState.update(modes[newMode])
            else
                dz.log('No mode change required',dz.LOG_DEBUG )
            end
        end

        --main
        dz.log('temperature: ' .. temperature ..', setpoint: ' .. setpoint ..', mode: ' .. mode2Text(mode),dz.LOG_DEBUG )
        if ( temperature - setpoint ) > hysteresis then  -- Temperature too high stop heating
            updateMode('idle')
        elseif ( setpoint - temperature ) > hysteresis then -- Temperature too low start heating
            updateMode('heating' ) 
        else
            dz.log('No mode change required',dz.LOG_DEBUG )
        end

    end
}
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: How to change thermostat operating state  [Solved]

Post by sailmich »

It just change the text from idle to heating and back versus. But on the thermostat itself the state doesn't change. :cry: Seems I was to early to happy.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest