Page 1 of 1

dzvents - openurl - postdata

Posted: Tuesday 25 June 2019 23:18
by fanabullunet
Domoticz V4.10717
Plateform : Rpi 3
OS : Raspbian stretch

Hello,

I'm struggling while trying to sent a command to my Philips TV, for example, to set to volume to a given value with the OpenUrl command.

- The URL that has to be used is something like : http://ip-address:1925/1/audio/volume
- The method that should be used is POST
- I guess the parameters intended to my tv should be set in the postdata parameter of the OpenUrl command.

The postdata should be a JSON object ressembling to :
{
"muted": false,
"current": 18
}


This is relatively well documented here:
http://jointspace.sourceforge.net/proje ... -POST.html

However, when I use the domoticz.OpenUrl command, the data shown in the postdata is always empty, whatever the syntax I use to specify the JSON object.

Did someone already face this kind of issues with the openurl command, or does anyone have a example of how he dealed with sending commands to a Philips TV ?

I have tried out more or less all I could think about, unfortunately, still unsuccessfull.

If I do the same without postdata and with the GET method (to get the current volume), this runs fine, so the URL is most probably correct.

Thank you so much to the one(s) who could help me there. I'm trying to find out the solution over 3 days. Now, I'm out of ideas :-(

Re: dzvents - openurl - postdata

Posted: Wednesday 26 June 2019 0:24
by waaren
fanabullunet wrote: Tuesday 25 June 2019 23:18 I'm struggling while trying to sent a command to my Philips TV, for example, to set to volume to a given value with the OpenUrl command.
Don't know what you already tried but should be something like this.

Code: Select all

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

    logging = { level = domoticz.LOG_DEBUG, marker = 'post data' },

    execute = function(dz, item)

        local targetIP = '192.168.xxx.xxx' -- Change to IP or dns of your TV 
   
        local function setVolume(volume)
            url = 'http://' .. targetIP .. ':1925/1/audio/volume'
            dz.openURL(
            {
                url = url,
                method = 'POST',
                callback = 'mycallbackstring',
                postData = 
                {
                    muted = false,
                    current = volume,
                }
            })
        end

        if item.isTimer then
            setVolume(8)
        else
            domoticz.log('Response from TV: ' .. item.data )
        end      
   end
}

Re: dzvents - openurl - postdata

Posted: Wednesday 26 June 2019 19:01
by fanabullunet
Hi waaren

thank you for your reply. Will test it and let you know ;-)

Re: dzvents - openurl - postdata

Posted: Wednesday 26 June 2019 19:39
by fanabullunet
Hi waaren,

it seems so silly once it works ! So, good news, the answer is below :-D

The problem was that, my postData was coded this way:
postData =
{
"muted": false,
"current": 18,
}
instead of:
postData =
{
muted = false,
current = 18,
}

Thanks you !