Can't Fix Sabnzbd Post Upgrade

Somehow I broke my Sabznbd sensor. I’m hoping a second pair of eyes can help.

In my HA/Sensors folder:

- platform: sabnzbd
  name: SAB
  api_key: KeyGoesHere
  host: 192.168.1.150
  port: 9090
  monitored_variables:
    - 'current_status'
    - 'speed'
    - 'queue_size'
    - 'queue_remaining'

HA logs spits out the following:

16-08-28 17:12:33 homeassistant.components.sensor.sabnzbd: Connection to SABnzbd API failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/connection.py", line 75, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.4/socket.py", line 533, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 595, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 363, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.4/http/client.py", line 1088, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.4/http/client.py", line 922, in _send_output
    self.send(msg)
  File "/usr/lib/python3.4/http/client.py", line 857, in send
    self.connect()
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 167, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 151, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7fe17989a198>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 640, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/retry.py", line 287, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='https', port=80): Max retries exceeded with url: //192.168.1.150:9090/api?mode=qstatus&apikey=KeyGoesHere&output=json (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fe17989a198>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/opt/homeassistant/deps/pysabnzbd/__init__.py", line 38, in check_available
    response = requests.get(url, params=api_args, timeout=5)
  File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='https', port=80): Max retries exceeded with url: //192.168.1.150:9090/api?mode=qstatus&apikey=KeyGoesHere&output=json (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fe17989a198>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/sensor/sabnzbd.py", line 65, in setup_platform
    sab_api.check_available()
  File "/var/opt/homeassistant/deps/pysabnzbd/__init__.py", line 43, in check_available
    raise SabnzbdApiException("Failed to communicate with SABnzbd API.")
pysabnzbd.SabnzbdApiException: Failed to communicate with SABnzbd API.

If I type https://192.168.1.150:9090/api?mode=qstatus&apikey=KeyGoesHere&output=json into my browser though, I get a nice output though

{"noofslots_total": 0, "have_warnings": "3", "pp_active": false, "mb": 0.0, "speedlimit_abs": "", "jobs": [], "noofslots": 0, "paused": false, "pause_int": "0", "state": "IDLE", "loadavg": "0.15 | 0.24 | 0.29 | V=4598M R=211M", "mbleft": 0.0, "diskspace2": 1925.5283203125, "diskspace1": 8.65057373046875, "kbpersec": 0.0, "speedlimit": "100", "timeleft": "0:00:00", "speed": "0 "}

Any ideas? Does it have to do with the fact that I run SAB as https? I’ve tried every combination of host (with and without port number) and port config lines but can’t get it to clear the error.

i’m also having same issue since upgrading to 0.27 and I’ve updated my settings just like you.

I was getting similar errors. I worked around it by having HASS connect without SSL.
The below config is working for me without error.

- platform: sabnzbd
  name: SAB
  api_key: [redacted]
  host: 10.69.42.32
  port: 8080
  monitored_variables:
    - 'current_status'
    - 'speed'
    - 'queue_size'
    - 'queue_remaining'
    - 'disk_size'
    - 'disk_free'

It should also be mentioned the sensor names don’t match the monitored variable names. This probably isn’t an issue for the two of you, since you had it working previously, but for anyone trying to set this up for the first time, the sensors are called “sab” instead of “sabnzbd”. A group might look like the following:

    Sabnzbd:
      view: no
      name: Sabnzbd
      entities:
       - sensor.sab_status
       - sensor.sab_speed
       - sensor.sab_queue
       - sensor.sab_left
       - sensor.sab_disk
       - sensor.sab_disk_free

This goes against expectations (in my opinion), and I submitted a pull to add the above to the documentation. I don’t know the component well enough to troubleshoot the SSL bug, however.

It’s not an SSL bug. About two weeks ago I migrated the Sabnzbd sensor to voluptuous for the configuration check and change a couple of thing. I missed to add an option for SSL/TLS. Sorry for the trouble.

Here is the issue. Otherwise I will forget to fix it during the weekend.

https://github.com/home-assistant/home-assistant/issues/3150

Sweet! Thanks for the fix fabaff!