http correct answer from socket or how to send http updates

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

Moderator: leecollings

Post Reply
Inso
Posts: 7
Joined: Thursday 12 October 2017 23:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

http correct answer from socket or how to send http updates

Post by Inso »

Hi,

I have set up a socket on my pc via java to receive updates.
on dzVents, as soon as the device is updated, I send the new data as a Json string using

Code: Select all

domoticz.openURL(URL)
which works fine, data is sent. However, after a litte time domotics shows me the error:

Code: Select all

Error: Error opening url: http://192.168.178.24:4242/{"idx":"85","Name":"Lux StudyRoom Inside Table","Data":"0 Lux","Type":"Lux","LastUpdate":"2018-11-26 23:44:14"}
I assume it is because I just parse the received data. My question is: what "answer" is Domoticz waiting for, what do I have to send back? Or, is there a way to "fire and forget"-send data?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: http correct answer from socket or how to send http updates

Post by waaren »

Inso wrote: Monday 26 November 2018 23:54 I have set up a socket on my pc via java to receive updates.
I assume it is because I just parse the received data. My question is: what "answer" is Domoticz waiting for, what do I have to send back? Or, is there a way to "fire and forget"-send data?
Can you just return OK ? Domoticz does not like an empty response ( statusCode 52 ) and report an error in the log

Code: Select all

return 

{
        on  =   {   timer           = { "every minute"},
        -- on  =   {   timer           = { "never"},
                    httpResponses   = { 'getLog' },
                },
                
    logging =   {   level           =   domoticz.LOG_DEBUG,
                    marker          =   "dumper 7",
                },
    
    execute = function(dz, item )
    
        if item.isTimer then
            local json = '{"idx":"85","Name":"Lux StudyRoom Inside Table","Data":"0 Lux","Type":"Lux","LastUpdate":"2018-11-26 23:44:14"}'
            dz.openURL(
                            {   url         = "http://192.168.178.24:4242/" .. json,
                                method      = "GET",
                                callback    = "getLog" ,
                            }
                        )
        else
            dz.log(item.statusCode,dz.LOG_DEBUG)
            dz.log(item.data,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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest