Page 1 of 1

Get Status of Evohome in LUA

Posted: Tuesday 06 August 2019 20:19
by JuanUil
Hi,

I want to use the status of my Evotouch ic Normal, away, day off aso to trigger some events.
Anybody can help me to get the status of the evotouch?
I tried otherdevices_svalues (to string) but I only get as a result nil.

thanx in advance

Jan

Re: Get Status of Evohome in LUA

Posted: Tuesday 06 August 2019 22:06
by JuanUil
looked in the wiki allready and also surch the forum with no result ;)

Re: Get Status of Evohome in LUA

Posted: Wednesday 07 August 2019 21:17
by JuanUil
no one?

Re: Get Status of Evohome in LUA

Posted: Saturday 10 August 2019 17:28
by JuanUil
realy nobody who could help me on the way?

Re: Get Status of Evohome in LUA

Posted: Saturday 10 August 2019 18:06
by waaren
JuanUil wrote:realy nobody who could help me on the way?
Do you see the status somewheree in the gui?





Re: Get Status of Evohome in LUA

Posted: Saturday 10 August 2019 18:53
by JuanUil
Yes status of each unit is displayed (away, normal, weekend a.s.o.)

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 10:03
by waaren
Can you try this dzVents script ? If it is does not show the information you need, uncomment the dump statement to see all available attributes and methods in the log.

Code: Select all

return  {
            on          =   { timer = {'every minute'}},   -- <<< --- set activity time 

            logging     =   {   
                                level           =   domoticz.LOG_DEBUG,
                                marker          =   "Evohome" 
                            },

    execute = function(dz)

        evoTouch = dz.devices('Vloer verw') -- Change to the name of your device
        for key, data in ipairs(evoTouch.rawData) do
            dz.log(evoTouch.name .. '; rawData[' .. key .. '] = ' .. data,dz.LOG_DEBUG)
        end
        -- evoTouch.dump() -- uncomment to show all attributes and methods.
    end
} 

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 13:51
by JuanUil
Hi Waaren

Thnx for the reply.
I have never used dzvents. can I just name it as a lua script and plce it in the dzvents folder?

sorry for the noob question.

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 14:24
by waaren

JuanUil wrote: I have never used dzvents. can I just name it as a lua script and plce it in the dzvents folder?
No problem. If you use the internal domoticz event editor, store it as dzVents type.
Using dzVents is not complicated but does require a 5 minuten read to get started.

When not yet familiar with dzVents please start with reading Get started Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."






Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 14:59
by JuanUil
Hi Waaren,

This is what I get:

Code: Select all

 2019-08-11 14:58:00.332 Status: dzVents: > wday: 1
2019-08-11 14:58:00.332 Status: dzVents: > hour: 14
2019-08-11 14:58:00.332 Status: dzVents: > yday: 223
2019-08-11 14:58:00.332 Status: dzVents: > year: 2019
2019-08-11 14:58:00.332 Status: dzVents: > day: 11
2019-08-11 14:58:00.332 Status: dzVents: > isUTC: false
2019-08-11 14:58:00.333 Status: dzVents: > yday: 221
2019-08-11 14:58:00.333 Status: dzVents: > ruleMatchesTime()
2019-08-11 14:58:00.333 Status: dzVents: > msAgo: 157752135
2019-08-11 14:58:00.333 Status: dzVents: > ruleIsInWeek()
2019-08-11 14:58:00.333 Status: dzVents: > secondsSinceMidnight: 68928
2019-08-11 14:58:00.333 Status: dzVents: > daysAgo: 1
2019-08-11 14:58:00.333 Status: dzVents: > milliSeconds: 0
2019-08-11 14:58:00.333 Status: dzVents: > minutesAgo: 2629
2019-08-11 14:58:00.333 Status: dzVents: > day: 9
2019-08-11 14:58:00.333 Status: dzVents: > wday: 6
2019-08-11 14:58:00.333 Status: dzVents: > minutes: 8
2019-08-11 14:58:00.333 Status: dzVents: > raw: 2019-08-09 19:08:48
2019-08-11 14:58:00.334 Status: dzVents: > startPlaylist()
2019-08-11 14:58:00.334 Status: dzVents: > disarm()
2019-08-11 14:58:00.334 Status: dzVents: > hardwareType: Evohome via Web API
2019-08-11 14:58:00.334 Status: dzVents: > kodiPause()
2019-08-11 14:58:00.334 Status: dzVents: > maxDimLevel: 0
2019-08-11 14:58:00.334 Status: dzVents: > updateText()
2019-08-11 14:58:00.334 Status: dzVents: > setVolume()
2019-08-11 14:58:00.334 Status: dzVents: > isGroup: false
2019-08-11 14:58:00.334 Status: dzVents: > hardwareId: 11
2019-08-11 14:58:00.334 Status: dzVents: > protected: false
2019-08-11 14:58:00.334 Status: dzVents: > nValue: 2
2019-08-11 14:58:00.334 Status: dzVents: > updateMode()
2019-08-11 14:58:00.334 Status: dzVents: > pause()
2019-08-11 14:58:00.334 Status: dzVents: > setValues()
2019-08-11 14:58:00.334 Status: dzVents: > _nValue: 2
2019-08-11 14:58:00.334 Status: dzVents: > sValue: Away
2019-08-11 14:58:00.334 Status: dzVents: > protectionOff()
2019-08-11 14:58:00.334 Status: dzVents: > play()
2019-08-11 14:58:00.334 Status: dzVents: > setDiscoMode()
2019-08-11 14:58:00.335 Status: dzVents: > updateHumidity()
2019-08-11 14:58:00.335 Status: dzVents: > baseType: device
2019-08-11 14:58:00.335 Status: dzVents: > setState()
2019-08-11 14:58:00.335 Status: dzVents: > updateCounter()
2019-08-11 14:58:00.335 Status: dzVents: > updateElectricity()
2019-08-11 14:58:00.335 Status: dzVents: > description:
2019-08-11 14:58:00.335 Status: dzVents: > onkyoEISCPCommand()
2019-08-11 14:58:00.335 Status: dzVents: > updateWeight()
2019-08-11 14:58:00.335 Status: dzVents: > playFavorites()
2019-08-11 14:58:00.335 Status: dzVents: > update()
2019-08-11 14:58:00.335 Status: dzVents: > hardwareTypeValue: 75
2019-08-11 14:58:00.335 Status: dzVents: > switchOff()
2019-08-11 14:58:00.335 Status: dzVents: > setColor()
2019-08-11 14:58:00.335 Status: dzVents: > deviceId: 3690529
2019-08-11 14:58:00.335 Status: dzVents: > updatePercentage()
2019-08-11 14:58:00.335 Status: dzVents: > armAway()
2019-08-11 14:58:00.335 Status: dzVents: > rename()
2019-08-11 14:58:00.335 Status: dzVents: > dump()
2019-08-11 14:58:00.335 Status: dzVents: > _data:
2019-08-11 14:58:00.335 Status: dzVents: > baseType: device
2019-08-11 14:58:00.336 Status: dzVents: > lastLevel: 0
2019-08-11 14:58:00.336 Status: dzVents: > description:
2019-08-11 14:58:00.336 Status: dzVents: > switchType: On/Off
2019-08-11 14:58:00.336 Status: dzVents: > lastUpdate: 2019-08-09 19:08:48
2019-08-11 14:58:00.336 Status: dzVents: > subType: Evohome
2019-08-11 14:58:00.336 Status: dzVents: > deviceID: 3690529
2019-08-11 14:58:00.336 Status: dzVents: > batteryLevel: 255
2019-08-11 14:58:00.336 Status: dzVents: > protected: false
2019-08-11 14:58:00.336 Status: dzVents: > data:
2019-08-11 14:58:00.336 Status: dzVents: > unit: 0
2019-08-11 14:58:00.336 Status: dzVents: > icon: override_mini
2019-08-11 14:58:00.336 Status: dzVents: > hardwareName: EVOHOME
2019-08-11 14:58:00.336 Status: dzVents: > hardwareTypeValue: 75
2019-08-11 14:58:00.336 Status: dzVents: > _nValue: 2
2019-08-11 14:58:00.336 Status: dzVents: > protected: false
2019-08-11 14:58:00.337 Status: dzVents: > maxDimLevel: 0
2019-08-11 14:58:00.337 Status: dzVents: > _state: Away
2019-08-11 14:58:00.337 Status: dzVents: > hardwareType: Evohome via Web API
2019-08-11 14:58:00.337 Status: dzVents: > hardwareID: 11
2019-08-11 14:58:00.337 Status: dzVents: > signalLevel: 255
2019-08-11 14:58:00.337 Status: dzVents: > id: 643
2019-08-11 14:58:00.337 Status: dzVents: > changed: false
2019-08-11 14:58:00.337 Status: dzVents: > switchTypeValue: 0
2019-08-11 14:58:00.337 Status: dzVents: > rawData:
2019-08-11 14:58:00.337 Status: dzVents: > timedOut: true
2019-08-11 14:58:00.337 Status: dzVents: > name: : EvoTouch
2019-08-11 14:58:00.337 Status: dzVents: > deviceType: Heating
2019-08-11 14:58:00.337 Status: dzVents: > stop()
2019-08-11 14:58:00.337 Status: dzVents: > setHex()
2019-08-11 14:58:00.337 Status: dzVents: > setWhiteMode()
2019-08-11 14:58:00.337 Status: dzVents: > bState: false
2019-08-11 14:58:00.337 Status: dzVents: > hardwareName: EVOHOME
2019-08-11 14:58:00.337 Status: dzVents: > setDescription()
2019-08-11 14:58:00.337 Status: dzVents: > updateSetPoint()
2019-08-11 14:58:00.338 Status: dzVents: > setRGB()
2019-08-11 14:58:00.338 Status: dzVents: > rawData:
2019-08-11 14:58:00.338 Status: dzVents: > activate()
2019-08-11 14:58:00.338 Status: dzVents: > deviceSubType: Evohome
2019-08-11 14:58:00.338 Status: dzVents: > isScene: false
2019-08-11 14:58:00.338 Status: dzVents: > setKelvin()
2019-08-11 14:58:00.338 Status: dzVents: > deviceType: Heating
2019-08-11 14:58:00.338 Status: dzVents: Info: Evohome: ------ Finished Script #2 

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 15:26
by JuanUil
By the way, I have a code to change the status, maybe this helps....

Code: Select all

os.execute('curl "http://192.168.2.18:8080/json.htm?type=command&param=switchmodal&idx=643&status=Away&action=1&ooc=1"')

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 16:45
by waaren
JuanUil wrote: Sunday 11 August 2019 14:59 This is what I get:
This is only part of the information. The internal logtab only shows the last 100 lines.
If you log to a file (see /etc/init.d/domoticz.sh , lines)

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS -log /var/log/domoticz.log"
DAEMON_ARGS="$DAEMON_ARGS -loglevel  normal,status,error"
You will get all

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 16:52
by waaren
JuanUil wrote: Sunday 11 August 2019 15:26 By the way, I have a code to change the status, maybe this helps....
Yes, then another other way to get the information is (from the CLI)

Code: Select all

curl "http://192.168.2.18:8080/json.htm?type=devices&rid=643"
but you should also see the information already if you use my example dzVents script.

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 18:14
by JuanUil
When I use the curl command in putty I get

Code: Select all

 "Data" : "Away",
but how can I get this to use in a LUA script

by the way I really appreciate your help so far!!

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 18:50
by waaren
JuanUil wrote: Sunday 11 August 2019 18:14 When I use the curl command in putty I get

Code: Select all

 "Data" : "Away",
but how can I get this to use in a LUA script

by the way I really appreciate your help so far!!
OK. This dzVents script should give you the status of your evohome touch

Code: Select all

return  {
            on          =   { timer = {'every minute'}},   -- <<< --- set activity time 

            logging     =   {   
                                level           =   domoticz.LOG_DEBUG,
                                marker          =   "Evohome" 
                            },

    execute = function(dz)

        evoTouch = dz.devices(643) -- Change to the "name" or id of your device
        
        dz.log("state of " .. evoTouch.name .. " = " .. evoTouch.sValue,dz.LOG_DEBUG) -- sValue attribute needs dzVents version > 2.4.20

    end
}

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 19:11
by JuanUil
Fantastic! This is working.
Could you help me with making this in LUA and store the state in a variable like status=text?
Hope I don't ask to much :o :o

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 21:00
by waaren
JuanUil wrote: Sunday 11 August 2019 19:11
Could you help me with making this in LUA and store the state in a variable like status=text?
I am not in favor of using classic domoticz Lua. Why would you use this as it is not the standard Lua but already adapted for use with domoticz using extra tables like commandArray, otherdevices and some more ? dzVents is 100% Lua but extended with a lot of useful methods and attributes, made available to the scripts using standard Lua code under the hood.

Not sure if you want a domoticz uservariable type string or an internal script variable. Check below script.

Code: Select all

return  {
            on          =   {   timer = {'every 1 minutes' }},  -- set time trigger

            logging     =   {   
                                level           =   domoticz.LOG_DEBUG,
                                marker          =   "Evohome" 
                            },
    execute = function(dz)
        local evoTouch = dz.devices(643) -- Change to the "name" or id of your device
        dz.log("state of " .. evoTouch.name .. " = " .. evoTouch.sValue,dz.LOG_DEBUG) -- sValue attribute needs dzVents version > 2.4.20

        local evoTouchState = evoTouch.sValue -- set local scriptVar to device state
        local evoVar = dz.variables('evotouch state') -- Change to "name" or id  of your domoticz uservariable (type string) 
        
        if evoVar.value ~= evoTouchState then
            evoVar.set(evoTouchState)
        end
    end
} 

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 21:05
by JuanUil
Oké I understand.
I will learn myself DZvents.
Gonna take me a while but finally I will succeed as I also succeded in learning LUA.

Thanks for all your help!!! Really great!!

Re: Get Status of Evohome in LUA

Posted: Sunday 11 August 2019 21:13
by waaren
JuanUil wrote: Sunday 11 August 2019 21:05 I will learn myself DZvents. Gonna take me a while but finally I will succeed as I also succeded in learning LUA.
Great !!
I would be surprised if it will take you more then an hour to let dzVents do stuff for you that you can do now already in domoticz Lua.