pilot Home automation

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

Moderator: leecollings

Post Reply
jandirkv
Posts: 27
Joined: Monday 19 February 2018 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9117
Contact:

pilot Home automation

Post by jandirkv »

Hello
I use pilot Home automation app to recieve Messages from domoticz. this goes through http messages where you fill in your key in field 1 and then with the following api url. I've added extra spaces because the complete url was not shown correctly
(In Field1 is my app code and in field2 of my girlfriend. see picture below
domoticz copy.jpg
domoticz copy.jpg (74.17 KiB) Viewed 592 times
the Problem is that the api url refers only to field1 so I only get the message. In DZvents I use this line (which works but only to my iPhone):

Code: Select all

domoticz.notify('message header', 'actual message','Prowl/NMS: Very Low, Pushover: N/A')
So I want to incorporate http://api.pilot.patrickferreira.com/#F ... T/#MESSAGE in my dzvents so I can send messages either to my iPhone (use field1 in the url) or to my girlfriends (use field2 in the url). Or if someone has another solution.
jandirkv
Posts: 27
Joined: Monday 19 February 2018 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9117
Contact:

Re: pilot Home automation

Post by jandirkv »

I already solved it. Here is my solution, maybe I can help someone else with it.

Code: Select all

domoticz.openURL('http://api.pilot.patrickferreira.com/'app code' without the quotes/'header' again without the quotes/'subject')
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: pilot Home automation

Post by dannybloe »

I have made a global helper (in global_data) where you can send Pilot messages to some or all known recipients. At the top I defined some users with their keys. And you can send messages like this:

Code: Select all

domoticz.helpers.notifyPilot(domoticz, 'Some subject', 'Some message', 'John')
domoticz.helpers.notifyPilot(domoticz, 'Some subject', 'Some message', 'all') -- send to all
domoticz.helpers.notifyPilot(domoticz, 'Some subject', 'Some message', {'John', 'Katy'})
I use this global function in all my scripts. Works like a charm and even encodes nasty characters in messages. Here is the code:

Code: Select all

local pilotUsers = {
    ['John'] = 'xxxx', -- use pilot key
    ['Mary'] = 'yyy',
    ['Katy'] = 'zzz'
}

return {
	helpers = {
	    notifyPilot = function(domoticz, subject, message, user)
	    
		if (subject == nil or subject == '') then
			subject = '–'
		end
		
		if (message == nil or message == '') then
			message = '–'
		end
	        
		--http://api.pilot.patrickferreira.com/KEY/SUBJECT/MESSAGE
		-- generic function for sending messages
		local _notifyUser = function(key, name)
			domoticz.log('Notify Pilot user: ' .. tostring(name) .. ';' .. tostring(subject) .. ';' .. tostring(message), domoticz.LOG_INFO)
			local msg = tostring(key) .. '/' .. domoticz.utils.urlEncode(subject .. '/' .. message, '%20')
			local url = 'http://api.pilot.patrickferreira.com/' .. msg
			domoticz.openURL(url)
		end
            
		if (user == 'All') then
			for name, key in pairs(pilotUsers) do
				_notifyUser(key, name)
			end
		elseif (type(user) == 'table') then
			for _, name in pairs(user) do
				_notifyUser(pilotUsers[name], name)
			end
		else
			_notifyUser(pilotUsers[user], user)
		end
	end
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest