React on RSS feed

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
Post Reply
MatthijsD
Posts: 45
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

React on RSS feed

Post by MatthijsD » Friday 08 September 2017 14:16

Hello!

Does anyone know if it is possible to use switches through a RSS feed?

Situation: I want to turn on lights as soon as a RSS feed gets a post with a specifiek strain of text.

Why: I'm a firefighter and I want to turn on certain lights as soon as I get a notification on my pager. Because the pager doesn't have a way to send anything, I want Domoticz to look at an RSS feed.

Can someone help me, or maybe even tell me to look in another direction than RSS?

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: React on RSS feed

Post by Westcott » Friday 08 September 2017 15:40

Python has an RSS feedreader library.
It seems to be possible in LUA as well, which makes integration easier.
How frequently would you want to check the feed?
Zwave - Sigma Z+ stick, Fibaro 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

MatthijsD
Posts: 45
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: React on RSS feed

Post by MatthijsD » Friday 08 September 2017 16:16

Thank you for your reply!

I'm running on Synology and would like to let it check every 5 seconds, only in a given timeframe.

MatthijsD
Posts: 45
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: React on RSS feed

Post by MatthijsD » Thursday 14 September 2017 14:00

Still unanswered and unsolved!
If anyone can help me out, that would be great :)

elmortero
Posts: 177
Joined: Sunday 29 November 2015 21:46
Target OS: Raspberry Pi
Domoticz version: 2.3852
Location: Spain
Contact:

Re: React on RSS feed

Post by elmortero » Thursday 14 September 2017 14:46

This LINK should help you get started.
It is simular to reading from a json table which has many examples here on the Domoticz forum.

MatthijsD
Posts: 45
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: React on RSS feed

Post by MatthijsD » Wednesday 20 September 2017 21:37

My script skills are sadly, very rusty.
I looked at other options and got the idea to use IFTTT web, to open an JSON url for a switch as soon as there is a new post in the RSS feed.
This, now resulting in automatically turning on the lights as soon as my pager goes off. Awesome :)

Thanks for the tips!

User avatar
NathanBlissett
Posts: 1
Joined: Monday 25 September 2017 10:21
Target OS: Windows
Domoticz version:
Contact:

Re: React on RSS feed

Post by NathanBlissett » Monday 25 September 2017 10:25

elmortero wrote:
Thursday 14 September 2017 14:46
This LINK should help you get started.
It is simular to reading from a json table which has many examples here on the Domoticz forum.
Thanks for sharing it, elmortero!

dverhall
Posts: 1
Joined: Wednesday 21 February 2018 19:08
Target OS: -
Domoticz version:
Contact:

Re: React on RSS feed

Post by dverhall » Wednesday 21 February 2018 19:11

Welke RSS feed gebruik je voor de meldingen?
Last edited by dverhall on Wednesday 21 February 2018 21:52, edited 1 time in total.

elmortero
Posts: 177
Joined: Sunday 29 November 2015 21:46
Target OS: Raspberry Pi
Domoticz version: 2.3852
Location: Spain
Contact:

Re: React on RSS feed

Post by elmortero » Wednesday 21 February 2018 21:27

dverhall wrote:
Wednesday 21 February 2018 19:11
Hello MatthijsD,

Can you please tell me how you fix it? I work also as a fire-fighter in Holland. Please contact me.
Ok, guys, I didn't realize it was for the P2000 stream.
This code might actually do what you need.
In it's current version it writes it's output to a text device and (as test, I do not live in Holland, I fitered on 'brand' in the URL and Amsterdam in the script. It also writes the detected CAP codes to another text sensor but you could for example have it flip a switch or start a scene on certen cap codes(you own personal or department code)

The code should be very straight forward and easy to customize to your needs.
Edit: I should mention this is dzVents (version from version 2.4 upward)

Code: Select all

return {
	on = {
		timer = { 'at every 3 minutes'},
		httpResponses = { 'P2000' } -- matches callback string below
	},
	
	execute = function(domoticz, triggerItem)
local sensor = domoticz.devices('P2000')
local currInfo = tostring(sensor.text)
local Csensor = domoticz.devices('CapCodes')
local CcurrInfo = tostring(Csensor.text)
		if (triggerItem.isTimer) then
			domoticz.openURL({
				url = 'https://p2000.phlux.eu/v1/event?query=Brand&limit=1',
				method = 'GET',
				callback = 'P2000'
			})
			--print('P2000 triggered by timer')
		elseif (triggerItem.isHTTPResponse) then

	local response = triggerItem
		if not response.isJSON then print('data is not jSon') end
		if (response.ok and response.isJSON) then
			--print('P2000 triggered by callback')
			tl = #response.json.events
			tc = 1
			 repeat
				local bericht = tostring(response.json.events[tc].title)
				if bericht ~= currInfo then
				    if string.find((string.lower(bericht)), "amsterdam") then
				       -- print('bericht gevonden: '..bericht)
				sensor.updateText(bericht)
				print('msg : '..bericht)				
					CE = #response.json.events[tc].capcodes
					ec = 1
					repeat
					 local CAPs = tostring(response.json.events[tc].capcodes[CE].capcode)
						 if CAPs ~= CcurrInfo then
						 --print('Capcode = '..CAPs)
						 Csensor.updateText(CAPs)
						 end
					 ec = ec + 1
				 until ec > CE
				 end
				end
				tc = tc + 1
			 until tc > tl

		end
			else
				print('**P2000 failed to fetch info')
			end
		
	end
}

eventeca
Posts: 4
Joined: Tuesday 13 February 2018 14:29
Target OS: -
Domoticz version:
Contact:

Re: React on RSS feed

Post by eventeca » Thursday 22 February 2018 7:17

Thank you so much!!

Post Reply

Who is online

Users browsing this forum: ala666cz and 6 guests