dzVents.lua Error  [Solved]

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

Moderator: leecollings

Post Reply
Sembo
Posts: 9
Joined: Sunday 03 September 2017 0:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hamburg
Contact:

dzVents.lua Error

Post 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)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents.lua Error

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Sembo
Posts: 9
Joined: Sunday 03 September 2017 0:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hamburg
Contact:

Re: dzVents.lua Error

Post 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 :-)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents.lua Error  [Solved]

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest