SabNZB Status

Python and python framework

Moderator: leecollings

Post Reply
User avatar
galadril
Posts: 828
Joined: Monday 07 September 2015 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

SabNZB Status

Post by galadril »

But with these script, you get the status of your sabNZB server

Prepare Domoticz
If you don't know how to create a virtual sensor chances are you have never done this before.
- Go to "Hardware"
- Fill in the name field with a desired name (like "Virtual")
- Choose for type the "Dummy, does nothing, use for virtual switches only"
- Click on "Add"
- The added hardware is now added to the hardware list. In the same row there is a "Create virtual sensor" button shown. Click on it.


Hardware
Now you are ready to create virtual devices.
- Go to "Hardware"
- Press "Create virtual sensor".
- Fill in the name field with a name like 'SabNZB'


Devices
Now you are ready to create a virtual device.
- Go to "Hardware"
- Press "Create virtual sensor".
- Fill in the name field with a name like 'SabNZB'


SabNZB script
Config the parameters in the Ginlong script:

Code: Select all

#config
sabnzb_key 			= '' 
sabnzb_server 		= '' 
sabnzb_port			= ''
	
#domoticz settings
domoticz_host      	= ''
domoticz_port      	= ''
domoticz_url       	= 'json.htm'
domoticz_sabnzb		= ''

Put the script under /domoticz/scripts and make the script executable:
"sudo chmod +x /home/pi/domoticz/scripts/sabnzb.py"


Test
Run the script by calling:
"sudo python /home/pi/domoticz/scripts/sabnzb.py"


Create the Cronjob
Now all ingredients are available to read the data from the portal and insert them into Domoticz.
- execute "sudo crontab -e"
- add the following line "*/5 * * * * /home/pi/domoticz/scripts/sabnzb.py"
- exit crontab. Now everything should be working for you.

Scripts
sabnzb.py

Code: Select all

#!/usr/bin/python
import urllib, urllib2, hashlib
from xml.etree import ElementTree as ET

#config
sabnzb_key 			= '' 
sabnzb_server 		= '' 
sabnzb_port			= ''
	
#domoticz settings
domoticz_host      	= ''
domoticz_port      	= ''
domoticz_url       	= 'json.htm'
domoticz_sabnzb		= ''

#building url
requestURL = 'http://'+sabnzb_server+':'+sabnzb_port+'/sabnzbd/api?mode=qstatus&output=xml&apikey='+sabnzb_key

#call sabnzb api
returnvalue = urllib.urlopen(requestURL)
root = ET.parse(returnvalue).getroot()
state = root.find('state').text

print 'SabNZB Status: '+state
urllib.urlopen("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=addlogmessage&message=SabNZB Status: "+state)

#uploading values to domoticz
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url+ "?type=command&param=udevice&idx=" + domoticz_sabnzb + "&nvalue=0&svalue=" + state)
urllib.urlopen(url)
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
Raspberry Piet
Posts: 158
Joined: Saturday 11 January 2014 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: SabNZB Status

Post by Raspberry Piet »

Sabnzbd my favorite!
I had a bash script once to get data like this into Domoticz. (i lost it)
Tried your script, and works. (use a virtual text sensor)

We can use [url]http://ip:port/sabnzbd/api?mode=queue&output=xml&apikey=xxxxxxxx[/url] to get more advanced data from Sabnzbd.
User avatar
galadril
Posts: 828
Joined: Monday 07 September 2015 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: SabNZB Status

Post by galadril »

Raspberry Piet wrote:We can use [url]http://ip:port/sabnzbd/api?mode=queue&output=xml&apikey=xxxxxxxx[/url] to get more advanced data from Sabnzbd.
You;re correct, i'll add some extra data to the scripts!
Thanks :)
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: SabNZB Status

Post by remb0 »

nice scripts. nzbget performance is much better on a synology so I don't use sabnzbd anymore..
anyone such nice scripts of nzbget?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: SabNZB Status

Post by Egregius »

Really? I like the way sabnzbd works. Nothing to worry about.
I do have quite a strong Syno, maybe that's way I don't notice it.
User avatar
galadril
Posts: 828
Joined: Monday 07 September 2015 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: SabNZB Status

Post by galadril »

I really like sabnzb, but Ill check nzbget to create a script
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: SabNZB Status

Post by dutchnld »

Hi thanks for your instructions!

I got the script working. At least when I run the test I received the SabNZBD status. :)

But I'm not so sure what type of virtual device I should use after clicking 'create virtual sensor'?

And what's the name of this variable? -> domoticz_sabnzb = ' '
Should that be the ID of the virtual sensor I have to create?

I'm quite new to crontab, when I edit this I read this example: 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
In your instructions it starts with a '/'. Is that correct? -> /5 * * * * /home/pi/domoticz/scripts/sabnzb.py
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
Raspberry Piet
Posts: 158
Joined: Saturday 11 January 2014 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: SabNZB Status

Post by Raspberry Piet »

dutchnld wrote:Hi thanks for your instructions!

I got the script working. At least when I run the test I received the SabNZBD status. :)

But I'm not so sure what type of virtual device I should use after clicking 'create virtual sensor'?
create a virtual text sensor
dutchnld wrote:And what's the name of this variable? -> domoticz_sabnzb = ' '
Should that be the ID of the virtual sensor I have to create?
yes idx number of the virtual text sensor you just made

dutchnld wrote:I'm quite new to crontab, when I edit this I read this example: 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
In your instructions it starts with a '/'. Is that correct? -> /5 * * * * /home/pi/domoticz/scripts/sabnzb.py
I use this for creating cronjobs : http://www.corntab.com/pages/crontab-gui
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: SabNZB Status

Post by dutchnld »

Thanks! I got it working now.

For the cron part I checked the log using 'grep CRON /var/log/syslog'
and got this error 'No MTA installed, discarding output'

I fixed that by using: sudo apt-get install postfix
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
BazemanKM
Posts: 35
Joined: Wednesday 22 July 2015 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: SabNZB Status

Post by BazemanKM »

Had to enter an extra s in the URL, because i was using https:

#building url
requestURL = 'https://'+sabnzb_server+':'+sabnzb_port+'/sabnzbd/api?mode=qstatus&output=xml&apikey='+sabnzb_key
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest