Re: PLEX status (dzVents)
Posted: Friday 08 May 2020 18:33
Thnx for feedback! enjoy!Alles geïnstalleerd en werkt redelijk goed!
Thnx for feedback! enjoy!Alles geïnstalleerd en werkt redelijk goed!
Did you already have a look at the customEvents section ?Number8 wrote: Tuesday 26 May 2020 14:50 So far in the test tab, there is a section with JSON data. I had no success so far get data delivered to Domoticz.
If the data is part of the url, it is already possible.Number8 wrote: Saturday 30 May 2020 11:46 Following a discussion I had with Tautulli dev https://www.reddit.com/r/Tautulli/comme ... emote_app/, this app send data using POST exclusively and not GET. Is there any chance that at some point Domoticz supports receiving DATA from a POST?
Code: Select all
curl -d '' "http://127.0.0.1:8084/json.htm?type=command¶m=customevent&event=myCustomEvent&data={test}"
Yes but no guarantee or even a timeline. No idea yet how much effort is involved and if there would be any security issues to consider.Number8 wrote: Tuesday 02 June 2020 8:19 So rephrase the request: is there any chance that customEvent API will be improved in order to accept a POST in order for a remote app to send data in the request body (instead of passing parameters directly in the URL).
The right place for suggestions is this subforumIs it the right place to suggest improvements or is there a better place to post suggestions? Thank you
I have created a Pull request JSON allow use of HTTP POST with postdata for dzvent's customEvents for this. Will be merged in a future beta if/when reviewers are OK with it.Number8 wrote: Tuesday 02 June 2020 8:19 Is there any chance that customEvent API will be improved in order to accept a POST
Open for testing in build 12126Number8 wrote: Friday 05 June 2020 13:29 I read that gizmocuz approved the idea. Good news! Wait and see now.
Yes on the receiving side (the script triggered by the customEvent) nothing changed.Number8 wrote: Friday 05 June 2020 21:15 Great! If I can I'll do some testing tomorrow. I guess JSON data is put in a table as for the GET?
That is what's expected.Number8 wrote: Saturday 06 June 2020 7:18 I have done several tests as a matter of fact using Tautulli. Nothing to report except that it works very well. It opens a lot of new possibilities. Simple question though: item.headers reports nil. Is it what one should expect, or am I doing something wrong?
Code: Select all
2020-06-06 09:15:00.476 Status: dzVents: Info: batch job script: ------ Start external script: batchjobs-v1.lua:, trigger: "at 9:15"
2020-06-06 09:15:00.476 Status: dzVents: Info: batch job script: starting daily backup
2020-06-06 09:15:00.479 Status: dzVents: Info: batch job script: ------ Finished batchjobs-v1.lua
2020-06-06 09:15:02.504 Status: Incoming connection from: 192.168.21.249
2020-06-06 09:15:11.481 (rasp-PetiteMaison) Temp + Humidity (Mobile)
2020-06-06 09:15:14.377 Status: dzVents: Info: plex script: ------ Start external script: plex.lua: Custom event: "plex"
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isJSON: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> data: {"action": "resume", "titre": "L'Arnaque"}
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isGroup: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isTimer: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isSecurity: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> trigger: plex
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isScene: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isHTTPResponse: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> type: customEvent
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isDevice: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isSystem: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> customEvent: plex
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isCustomEvent: true
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isHardware: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> dump()
2020-06-06 09:15:14.377 Status: dzVents: customEvent> status: info
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isVariable: false
2020-06-06 09:15:14.377 Status: dzVents: customEvent> message:
2020-06-06 09:15:14.377 Status: dzVents: customEvent> isXML: false
2020-06-06 09:15:14.377 Status: dzVents: Info: plex script: {["isJSON"]=false, ["data"]="{"action": "resume", "titre": "L'Arnaque"}", ["isGroup"]=false, ["isTimer"]=false, ["isSecurity"]=false, ["trigger"]="plex", ["isScene"]=false, ["isHTTPResponse"]=false, ["type"]="customEvent", ["isDevice"]=false, ["isSystem"]=false, ["customEvent"]="plex", ["isCustomEvent"]=true, ["isHardware"]=false, ["dump"]=nil, ["status"]="info", ["isVariable"]=false, ["message"]="", ["isXML"]=false}
2020-06-06 09:15:14.377 Status: dzVents: Info: plex script: ------ Finished plex.lua
2020-06-06 09:15:14.377 Error: dzVents: Error: (3.0.9) plex script: Error parsing json to LUA table: /home/pi/domoticz/scripts/dzVents/../lua/JSON.lua:1234: /home/pi/domoticz/scripts/dzVents/../lua/JSON.lua:808: expected comma or '}' at byte 34 of: {"action": "resume", "titre": "L"Arnaque"} According to the RFC, JSON strings cannot contain single quotes; hence the Lua JSON decoder does not allow them and throw an error.Number8 wrote: Saturday 06 June 2020 9:20 One little issue with the processing of single quote.
2020-06-06 09:15:14.377 Status: dzVents: Info: plex script: ------ Finished plex.lua
2020-06-06 09:15:14.377 Error: dzVents: Error: (3.0.9) plex script: Error parsing json to LUA table: /home/pi/domoticz/scripts/dzVents/../lua/JSON.lua/home/pi/domoticz/scripts/dzVents/../lua/JSON.lua:808: expected comma or '}' at byte 34 of: {"action": "resume", "titre": "L"Arnaque"} [/code]
As you see, the data section reports correctly the value " L'Arnaque " . However the JSON decoder tranforms the single quote in a double quote which makes it failing to recognize it is a regular json stream
Code: Select all
if not(item.json) then
item.json = dz.utils.fromJSON(item.data:gsub("'","\\u0027"))
end