Page 1 of 1

dzVents.lua Error

Posted: Wednesday 26 June 2019 22:11
by Sembo
Hey guys, need some help. My protocol looks like this. Actually, I am still playing around, but can someone have a look at this, especially at the advents error? I do not know what to do to fix it. What does the error mean?

2019-06-26 22:09:00.226 Status: dzVents: Woonkamer/Eetkamer Sonos Status: STOPPED
2019-06-26 22:09:00.226 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/Utils.lua:117: attempt to call global 'type' (a string value)
2019-06-26 22:09:01.089 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)
2019-06-26 22:09:10.852 (Sony TV) Pushing 'onHeartbeatCallback' on to queue
2019-06-26 22:09:10.856 (Sony TV) Processing 'onHeartbeatCallback' message
2019-06-26 22:09:10.856 (Sony TV) Calling message handler 'onHeartbeat'.
2019-06-26 22:09:10.878 (Sony TV) Status TV: active
2019-06-26 22:09:11.037 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)
2019-06-26 22:09:20.853 (Sony TV) Pushing 'onHeartbeatCallback' on to queue
2019-06-26 22:09:20.902 (Sony TV) Processing 'onHeartbeatCallback' message
2019-06-26 22:09:20.903 (Sony TV) Calling message handler 'onHeartbeat'.
2019-06-26 22:09:20.922 (Sony TV) Status TV: active
2019-06-26 22:09:21.062 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)
2019-06-26 22:09:30.855 (Sony TV) Pushing 'onHeartbeatCallback' on to queue
2019-06-26 22:09:30.888 (Sony TV) Processing 'onHeartbeatCallback' message
2019-06-26 22:09:30.888 (Sony TV) Calling message handler 'onHeartbeat'.
2019-06-26 22:09:30.909 (Sony TV) Status TV: active
2019-06-26 22:09:31.060 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)
2019-06-26 22:09:40.857 (Sony TV) Pushing 'onHeartbeatCallback' on to queue
2019-06-26 22:09:40.878 (Sony TV) Processing 'onHeartbeatCallback' message
2019-06-26 22:09:40.879 (Sony TV) Calling message handler 'onHeartbeat'.
2019-06-26 22:09:40.899 (Sony TV) Status TV: active
2019-06-26 22:09:41.079 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)
2019-06-26 22:09:41.374 Status: dzVents: Woonkamer/Eetkamer Sonos Status: STOPPED
2019-06-26 22:09:41.531 Status: dzVents: Woonkamer/Eetkamer Sonos Status: STOPPED
2019-06-26 22:09:41.651 Status: dzVents: Woonkamer/Eetkamer Sonos Status: STOPPED
2019-06-26 22:09:41.767 Status: dzVents: Woonkamer/Eetkamer Sonos Status: STOPPED
2019-06-26 22:09:41.374 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/Utils.lua:117: attempt to call global 'type' (a string value)
2019-06-26 22:09:41.531 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/Utils.lua:117: attempt to call global 'type' (a string value)
2019-06-26 22:09:41.651 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/Utils.lua:117: attempt to call global 'type' (a string value)
2019-06-26 22:09:41.767 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/dzVents/runtime/Utils.lua:117: attempt to call global 'type' (a string value)

2019-06-26 22:09:51.054 (Sony TV) Pushing 'onHeartbeatCallback' on to queue
2019-06-26 22:09:51.071 (Sony TV) Processing 'onHeartbeatCallback' message
2019-06-26 22:09:51.072 (Sony TV) Calling message handler 'onHeartbeat'.
2019-06-26 22:09:51.096 (Sony TV) Status TV: active
2019-06-26 22:09:51.222 (Sony TV) No information from TV received (TV was paused and then continued playing from disk)

Re: dzVents.lua Error

Posted: Thursday 27 June 2019 0:25
by waaren
Sembo wrote: Wednesday 26 June 2019 22:11 Hey guys, need some help. My protocol looks like this. Actually, I am still playing around, but can someone have a look at this, especially at the advents error? I do not know what to do to fix it. What does the error mean?
Hard to tell without knowing what your domoticz / dzVents version is. It would also help if you can share the script that is likely causing it and a little background on the circumstances. When did this error started and if it has been successful in the past, was there a change in your system / software.

Re: dzVents.lua Error

Posted: Sunday 30 June 2019 9:02
by Sembo
How to find out which dzVents version I am running?

Here is the script, which is running:

Code: Select all

active = true,
 // on = { ['timer'] = 'every minute' },
  execute = function(domoticz)

        local json = (loadfile "/home/pi/domoticz/scripts/lua/sonos_kueche.lua")()

        local sonos=assert(io.popen('curl http://192.168.2.121:5005/kueche/state'))
        local sonos_name = 'kueche'
        local Sonos_status = 'Sonos'

        local status = sonos:read('*all')
        sonos:close()
        local jsonStatus = json:decode(status)

        Sonos= jsonStatus['stationName']
        
        
        echo "Playing: " > /dev/null 2>&1

        Sonos= jsonStatus['stationName']                 # get string in var
        Sonos="${myvar// /%20}"       # prepare for curl (replace spaces with %20)


curl  http://192.168.2.121:8080/json.htm?type=command&param=udevice&idx=34&svalue=$Sonos
        

  end
}
My intention is the following:

I would like to have a Box which display the current played artist/song on the Sonos system. I know, the above script is "crap" but I am still gathering experience on LUA, so I am thankful for any feedback or input. Actually I am struggling with using variables, I get the whole response from the SONOS speaker in JSON format and the script should use "Stationname" from the reponse to display and update it in my dashboard.

here it is:

Code: Select all

{"volume":7,"mute":false,"equalizer":{"bass":0,"treble":0,"loudness":true},"currentTrack":{"artist":"Stereo Express","title":"Babayani - Original Mix","album":"Babayani","albumArtUri":"/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a60CSfCIS9cRfVWIp9K35eq%3fsid%3d9%26flags%3d8224%26sn%3d1","duration":452,"uri":"x-sonos-spotify:spotify%3atrack%3a60CSfCIS9cRfVWIp9K35eq?sid=9&flags=8224&sn=1","trackUri":"x-sonos-spotify:spotify%3atrack%3a60CSfCIS9cRfVWIp9K35eq?sid=9&flags=8224&sn=1","type":"track","stationName":"","absoluteAlbumArtUri":"https://pl.scdn.co/images/pl/default/b96362b61c1c4cd9a6730cdbf0d9e0a1de368de7"},"nextTrack":{"artist":"Maya Jane Coles","title":"Don't Leave","album":"Don't Leave","albumArtUri":"/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a6hIqD6NN5RfoTDE9Ze3FQW%3fsid%3d9%26flags%3d8224%26sn%3d1","duration":317,"uri":"x-sonos-spotify:spotify%3atrack%3a6hIqD6NN5RfoTDE9Ze3FQW?sid=9&flags=8224&sn=1","trackUri":"x-sonos-spotify:spotify%3atrack%3a6hIqD6NN5RfoTDE9Ze3FQW?sid=9&flags=8224&sn=1","absoluteAlbumArtUri":"http://192.168.2.113:1400/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a6hIqD6NN5RfoTDE9Ze3FQW%3fsid%3d9%26flags%3d8224%26sn%3d1"},"trackNo":8,"elapsedTime":297,"elapsedTimeFormatted":"00:04:57","playbackState":"PLAYING","playMode":{"repeat":"none","shuffle":false,"crossfade":false}}
Actually, there was no current change in my system but only my "playing" with scripts. But I do not really get the point how to realize my scenario. I do not understand how to use a variable out of a script to use it to display it in my Dashboard, but I will find out :-)

I already set the log to "full protocol" - do I need to clear it - I want to avoid getting out of memory on my PI :-)

Re: dzVents.lua Error  [Solved]

Posted: Sunday 30 June 2019 14:58
by waaren
Sembo wrote: Sunday 30 June 2019 9:02 How to find out which dzVents version I am running?
[SETUP][ABOUT]
the code does not work
You do not need to use curl. The script should be able to collect the data directly. It might be that you wil need a recent version ( >= 2.4.19) to be able to get statusText but only if the httpResponse encounter a problem

Code: Select all

local scriptVar = 'getSONOS'

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

    logging = { level = domoticz.LOG_DEBUG, marker = scriptVar },

    execute = function(dz, item)
        local playing = dz.devices('Playing now') -- Change to name of your text device 

        local function collectSonosJSON()
            local sonosURL = 'http://192.168.2.121:5005/kueche/state'
            dz.openURL(
            {
                url = sonosURL,
                callback = scriptVar
            })
        end

        local LF = '\r\n'
        if item.isTimer then
            collectSonosJSON()
        elseif item.nok and item.isJSON then 
            local sonosString = 'artist: ' ..  ( item.json.currentTrack.artist or '-' ) .. LF .. 'title: ' .. ( item.json.currentTrack.title  or '-' )
            playing.updateText(sonosString)
        else
            dz.log('Problem with response from Sonos: ' .. item.statusText  )
        end
   end
}