Custom http notification  [Solved]

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

Moderator: leecollings

User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Custom http notification

Post by Varazir »

Hello

I have written this and I just like to check if I could have done it in another way or if something is wrong.
Needed a bit mot flexible notification system.
API I'm using is from this site https://joaoapps.com/join/api/
I wised I could encrypt my message as well but then I need some thing i wrote in this script https://github.com/varazir/join/blob/ma ... message.pl ( top modules loaded ) and code
https://github.com/varazir/join/blob/11 ... ge.pl#L325

The API can be used to send command to my phone to execute and then I don't need the title and icon.

dzVents: global_data.lua

Code: Select all

	helpers = {
		join = function(dz, deviceId, command, title)
		    icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
		    toID = "&deviceId=" .. deviceId
		    if string.match(command, "=:=") then -- if command contains  "=:=" it's should not add title and a icon
		       message = "&text=" .. command
		    else
		        message = "&title=" .. title .. "&text=" .. command .. icon
		    end
		    message = message .. toID
			message = dz.urlEncode(message)
			dz.notify(message,dz.PRIORITY_NORMAL,dz.NSS_HTTP)
		end
	}
Last edited by Varazir on Wednesday 23 September 2020 21:53, edited 1 time in total.
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Wednesday 23 September 2020 21:38 I have written this and I just like to check if I could have done it in another way or if something is wrong.
I have no real clue what this is doing but I do see that the parms of dz.notify are not correct.
NSS.png
NSS.png (59.2 KiB) Viewed 1846 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Wednesday 23 September 2020 21:50
Varazir wrote: Wednesday 23 September 2020 21:38 I have written this and I just like to check if I could have done it in another way or if something is wrong.
I have no real clue what this is doing but I do see that the parms of dz.notify are not correct.

NSS.png
Well it's a over complicated way to use the http notification function in Domoticz :)
I guess I could just use the openurl() as well but then I need to have the API key in the script.


Strange as this command works just fine

Code: Select all

dz.notify("Aktuell grupp",control[selectedGroupNumber],dz.PRIORITY_NORMAL,dz.NSS_HTTP)
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

Example could be that if I wish my phone to run a command it sends a message like this
&text=domoticz=:=RunMytask

The Tasker app on my phone will pick up that command and execute what I have set it up to run.

But if I just want a notification on my phone I need something like this

&title=warning&text=Window%20open&icon=UrltoIcon
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Wednesday 23 September 2020 21:57 Strange as this command works just fine

Code: Select all

dz.notify("Aktuell grupp",control[selectedGroupNumber],dz.PRIORITY_NORMAL,dz.NSS_HTTP)
It might look like its OK but what you send is

subject:"Aktuell grupp"
message:control[selectedGroupNumber]
priority: dz.PRIORITY_NORMAL
sound: dz.NSS_HTTP -- ignored for all subsystems except pushover
extra: nil -- ignored
subsystem: nil -- send to all configured subsystems

And for the notify in you helper
dz.notify(message,dz.PRIORITY_NORMAL,dz.NSS_HTTP)

subject:message
message:dz.PRIORITY_NORMAL -- a number
priority: dz.NSS_HTTP -- a string
sound: nil -- ignored for all subsystems except pushover
extra: nil -- ignored
subsystem: nil -- send to all configured subsystems
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Wednesday 23 September 2020 22:07
Varazir wrote: Wednesday 23 September 2020 21:57 Strange as this command works just fine

Code: Select all

dz.notify("Aktuell grupp",control[selectedGroupNumber],dz.PRIORITY_NORMAL,dz.NSS_HTTP)
It might look like its OK but what you send is

subject:"Aktuell grupp"
message:control[selectedGroupNumber]
priority: dz.PRIORITY_NORMAL
sound: dz.NSS_HTTP -- ignored for all subsystems except pushover
extra: nil -- ignored
subsystem: nil -- send to all configured subsystems

And for the notify in you helper
dz.notify(message,dz.PRIORITY_NORMAL,dz.NSS_HTTP)

subject:message
message:dz.PRIORITY_NORMAL -- a number
priority: dz.NSS_HTTP -- a string
sound: nil -- ignored for all subsystems except pushover
extra: nil -- ignored
subsystem: nil -- send to all configured subsystems
I misread the wiki, is there a way to only send a subject or a message ?

just add a extra , ?
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Thursday 24 September 2020 18:52 I misread the wiki, is there a way to only send a subject or a message ?
Subject is the only required parameter. All other ones can be nil (implicit or explcit)

so

Code: Select all

domoticz.notify('subject') -- OK will send message to all configured subsystems
domoticz.notify('subject',nil,nil,nil,nil,dz.NSS_PUSHOVER) -- OK will send message to Pushover
domoticz.notify('subject',,,,,dz.NSS_PUSHOVER) -- NOT OK (lua does not recognize ,,)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Thursday 24 September 2020 20:47
Varazir wrote: Thursday 24 September 2020 18:52 I misread the wiki, is there a way to only send a subject or a message ?
Subject is the only required parameter. All other ones can be nil (implicit or explcit)

so

Code: Select all

domoticz.notify('subject') -- OK will send message to all configured subsystems
domoticz.notify('subject',nil,nil,nil,nil,dz.NSS_PUSHOVER) -- OK will send message to Pushover
domoticz.notify('subject',,,,,dz.NSS_PUSHOVER) -- NOT OK (lua does not recognize ,,)
Okay the wiki wasn't that clear about that.

I got it half way now.

This is the original url I have in the https notification settings

Code: Select all

https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?apikey=#FIELD1&title=#SUBJECT&text=#MESSAGE&deviceId=#TO&icon=#FIELD2
Works just fine but if I change it to

Code: Select all

https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?apikey=#FIELD1#SUBJECT
Nothing happens, I don't get any errors in the log.

The current script

Code: Select all

	helpers = {
		join = function(dz, deviceId, command, title)
		    icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
		    toID = "&deviceId=" .. deviceId
		    if string.match(command, "=:=") then 
		       message = "&text=" .. command
		    else
		        title = dz.urlEncode(title)
		        command = dz.urlEncode(command)
		        message = "&title=" .. title .. "&text=" .. command .. icon
		    end
		    message = message .. toID
			dz.notify(message,nil,nil,nil,dz.PRIORITY_NORMAL,dz.NSS_HTTP)
		end
	}
I call it like this:

Code: Select all

dz.helpers.join(dz,"group.all","domoticz","SovrumGN")
It looks okay in the log as far as I can understand it. would love the to see the whole https command
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Thursday 24 September 2020 21:59 It looks okay in the log as far as I can understand it. would love the to see the whole https command
I guess I miss your point but if your objective is to send a url why taking the detour via dz.notify?
You might want to try the domoticz.openURL() method instead.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote:
Varazir wrote: Thursday 24 September 2020 21:59 It looks okay in the log as far as I can understand it. would love the to see the whole https command
I guess I miss your point but if your objective is to send a url why taking the detour via dz.notify?
You might want to try the domoticz.openURL() method instead.
Been thinking of that. My concern is to have the api key in the script.

Skickat från min EML-L29 via Tapatalk

Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote:Been thinking of that. My concern is to have the api key in the script.
You could store the key in a domoticz uservariable and retrieve it during script execution. You might want to use base64 code/decode for that to ensure the password is not direct readable.
(or encryption / decryption if you really want to make it fancy)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Friday 25 September 2020 9:30
Varazir wrote:Been thinking of that. My concern is to have the api key in the script.
You could store the key in a domoticz uservariable and retrieve it during script execution. You might want to use base64 code/decode for that to ensure the password is not direct readable.
(or encryption / decryption if you really want to make it fancy)
That is a solution, I'll tak a look at that.

Do Domoticz have PBKDF2, CBC/AES encryption support ?
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Sunday 27 September 2020 9:44 That is a solution, I'll tak a look at that.
Do Domoticz have PBKDF2, CBC/AES encryption support ?
Don't know but dzVents has not natively. You could use external Lua to do that but for this purpose I guess you could also use
dz.utils.toBase64 / dz.utils.fromBase64 and add your own key to the coded string before storing (and remove it before using) to obscure it even more.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Sunday 27 September 2020 11:49
Varazir wrote: Sunday 27 September 2020 9:44 That is a solution, I'll tak a look at that.
Do Domoticz have PBKDF2, CBC/AES encryption support ?
Don't know but dzVents has not natively. You could use external Lua to do that but for this purpose I guess you could also use
dz.utils.toBase64 / dz.utils.fromBase64 and add your own key to the coded string before storing (and remove it before using) to obscure it even more.
Hmm okay, is there a way to call a external perl script and get value back ?
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Sunday 27 September 2020 18:01 Is there a way to call a external perl script and get value back ?
Yes if you are on the latest Beta you can use

Code: Select all

returnValue, returnCode = dz.utils.osCommand('perl /pathToScript/scriptName.pl')
If on an older version

use

Code: Select all

        local function osCommand(cmd)
            dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)

            local fileHandle = assert(io.popen(cmd))
            local commandOutput = assert(fileHandle:read('*a'))
            local returnTable = {fileHandle:close()}

            dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
            return commandOutput,returnTable[3] -- rc[3] contains returnCode
        end

returnValue, returnCode = osCommand('perl /pathToScript/scriptName.pl'
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Sunday 27 September 2020 22:17 Yes.
Ya I'm using beta

Something like this then ?

Code: Select all

return {
	-- global persistent data
	data = {
		-- myGlobalVar = { initial = 12 }
	},
	-- global helper functions
	helpers = {
		join = function(dz, deviceId, command, title)
		    icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
		    toID = "&deviceId=" .. deviceId
		    JoinKey = "apikey=" .. dz.variables('JoinKey')
		    JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
		    if string.match(command, "=:=") then 
		       message = "&text=" .. command
		    else
		        title = dz.urlEncode(title)
		        command = dz.urlEncode(command)
		        message = "&title=" .. title .. "&text=" .. command .. icon
		    end
		    returnMessage, returnCode = dz.utils.osCommand('perl /opt/join/encode.pl' .. message )
		    message = JoinKey .. returnMessage .. toID
		    
		    dz.openurl( JoinURL .. message )
		    
			-- dz.notify(message,nil,nil,nil,dz.PRIORITY_NORMAL,dz.NSS_HTTP)
		end
	}
}
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Monday 28 September 2020 14:22
waaren wrote: Sunday 27 September 2020 22:17 Yes.
Ya I'm using beta

Something like this then ?
Some typos in your code... See my remarks

Code: Select all

return 
{
	-- global helper functions
	helpers = {
		join = function(dz, deviceId, command, title)
		    icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
		    toID = "&deviceId=" .. deviceId
		    JoinKey = "apikey=" .. dz.variables('JoinKey').value -- You only need the value; not the complete variable object 
 		    JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
		    if string.match(command, "=:=") then 
		       message = "&text=" .. command
		    else
		        title = dz.utils.urlEncode(title) -- urlEncode is a method in utils 
		        command = dz.utils.urlEncode(command)
		        message = "&title=" .. title .. "&text=" .. command .. icon
		    end
		    returnMessage, returnCode = dz.utils.osCommand('perl /opt/join/encode.pl ' .. message ) -- mind the space before the message parm 
		    message = JoinKey .. returnMessage .. toID
		    
		    dz.openurl( JoinURL .. message )
		    
		end
	}
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote: Monday 28 September 2020 15:58
Varazir wrote: Monday 28 September 2020 14:22
waaren wrote: Sunday 27 September 2020 22:17 Yes.
Ya I'm using beta

Something like this then ?
Some typos in your code... See my remarks

Code: Select all

return 
{
	-- global helper functions
	helpers = {
		join = function(dz, deviceId, command, title)
		    icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
		    toID = "&deviceId=" .. deviceId
		    JoinKey = "apikey=" .. dz.variables('JoinKey').value -- You only need the value; not the complete variable object 
 		    JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
		    if string.match(command, "=:=") then 
		       message = "&text=" .. command
		    else
		        title = dz.utils.urlEncode(title) -- urlEncode is a method in utils 
		        command = dz.utils.urlEncode(command)
		        message = "&title=" .. title .. "&text=" .. command .. icon
		    end
		    returnMessage, returnCode = dz.utils.osCommand('perl /opt/join/encode.pl ' .. message ) -- mind the space before the message parm 
		    message = JoinKey .. returnMessage .. toID
		    
		    dz.openurl( JoinURL .. message )
		    
		end
	}
}
Hmm, I got stuck

I'm getting

Code: Select all

2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) An error occurred when calling event handler test
2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) ...moticz/scripts/dzVents/generated_scripts/global_data.lua:31: attempt to call a nil value (field 'osCommand'
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Custom http nonfiction

Post by waaren »

Varazir wrote: Wednesday 30 September 2020 19:09 Hmm, I got stuck
I'm getting

Code: Select all

2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) An error occurred when calling event handler test
2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) ...moticz/scripts/dzVents/generated_scripts/global_data.lua:31: attempt to call a nil value (field 'osCommand'
dz.utils.osCommand is available in dzVents versions >= 3.0.13 (domoticz version 2002.2 build 12394) If you cannot upgrade to that Beta version yet you will have to include the function I posted earlier (see below to see how.

Code: Select all

return
{
    -- global helper functions
    helpers = 
    {
        join = function(dz, deviceId, command, title)

            local function osCommand(cmd)
                dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)

                local fileHandle = assert(io.popen(cmd))
                local commandOutput = assert(fileHandle:read('*a'))
                local returnTable = {fileHandle:close()}

                dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
                return commandOutput,returnTable[3] -- rc[3] contains returnCode
            end

            icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
            toID = "&deviceId=" .. deviceId
            JoinKey = "apikey=" .. dz.variables('JoinKey').value -- You only need the value; not the complete variable object
             JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
            if string.match(command, "=:=") then
               message = "&text=" .. command
            else
                title = dz.utils.urlEncode(title) -- urlEncode is a method in utils
                command = dz.utils.urlEncode(command)
                message = "&title=" .. title .. "&text=" .. command .. icon
            end
            returnMessage, returnCode = osCommand('perl /opt/join/encode.pl ' .. message ) -- mind the space before the message parm
            message = JoinKey .. returnMessage .. toID

            dz.openurl( JoinURL .. message )

        end
    }
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 487
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Custom http nonfiction

Post by Varazir »

waaren wrote:
Varazir wrote: Wednesday 30 September 2020 19:09 Hmm, I got stuck
I'm getting

Code: Select all

2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) An error occurred when calling event handler test
2020-09-30 19:05:25.258 Error: dzVents: Error: (3.0.12) ...moticz/scripts/dzVents/generated_scripts/global_data.lua:31: attempt to call a nil value (field 'osCommand'
dz.utils.osCommand is available in dzVents versions >= 3.0.13 (domoticz version 2002.2 build 12394) If you cannot upgrade to that Beta version yet you will have to include the function I posted earlier (see below to see how.

Code: Select all

return
{
    -- global helper functions
    helpers = 
    {
        join = function(dz, deviceId, command, title)

            local function osCommand(cmd)
                dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)

                local fileHandle = assert(io.popen(cmd))
                local commandOutput = assert(fileHandle:read('*a'))
                local returnTable = {fileHandle:close()}

                dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
                return commandOutput,returnTable[3] -- rc[3] contains returnCode
            end

            icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
            toID = "&deviceId=" .. deviceId
            JoinKey = "apikey=" .. dz.variables('JoinKey').value -- You only need the value; not the complete variable object
             JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
            if string.match(command, "=:=") then
               message = "&text=" .. command
            else
                title = dz.utils.urlEncode(title) -- urlEncode is a method in utils
                command = dz.utils.urlEncode(command)
                message = "&title=" .. title .. "&text=" .. command .. icon
            end
            returnMessage, returnCode = osCommand('perl /opt/join/encode.pl ' .. message ) -- mind the space before the message parm
            message = JoinKey .. returnMessage .. toID

            dz.openurl( JoinURL .. message )

        end
    }
}
I'm running

About Domoticz
Version: 2020.2 (build 12393)
Build Hash: 46660897d-modified
Compile Date: 2020-09-21 13:52:00
dzVents Version: 3.0.12
Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]


See it now, well I have to wait for next beta release.

Skickat från min EML-L29 via Tapatalk


Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest