From 5dbd554a108205e58c6c61b26075c4eb0a217334 Mon Sep 17 00:00:00 2001 From: bigwoof Date: Wed, 22 Nov 2017 00:35:23 +1000 Subject: [PATCH] Adding Queue count sensor (#10723) Adding another sensor to output the numeber of items in the SABnabd queue. This is an alternative to displaying filesize, just a preference thing, as it is more meaningfull for me the way I use SABnzdb. Note this is my first time coding on github and I have no idea if I am doing things right, I assume that all I needed to do is add a couple of lines to the sensors available and also another line as to what to extract from the SABnzdb API, in this case I have called the sensor "queue_count" and it gets the value from the noofslots_total which as I understand - each slot is a separate download item. hope I did this correctly - also I don't have a separate instance of home assistant running for testing so I have no way to test this code (and I don't know how I would switch to the dev channel either). As I said I am a newb! --- homeassistant/components/sensor/sabnzbd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index f034755e780..9ce2da09451 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -40,6 +40,7 @@ SENSOR_TYPES = { 'queue_remaining': ['Left', 'MB'], 'disk_size': ['Disk', 'GB'], 'disk_free': ['Disk Free', 'GB'], + 'queue_count': ['Queue Count', None], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -211,5 +212,7 @@ class SabnzbdSensor(Entity): self._state = self.sabnzb_client.queue.get('diskspacetotal1') elif self.type == 'disk_free': self._state = self.sabnzb_client.queue.get('diskspace1') + elif self.type == 'queue_count': + self._state = self.sabnzb_client.queue.get('noofslots_total') else: self._state = 'Unknown'