Giter VIP home page Giter VIP logo

python-wink's Introduction

Python Wink API

Join the chat at https://gitter.im/python-wink/python-wink Build Status Coverage Status

This library is an attempt to implement the entire Wink API in Python 3. Documentation for the Wink API can be found here http://docs.winkapiv2.apiary.io/# however, from my experience it isn't kept up-to-date.

This library also has support for the unoffical local API and doesn't require a rooted hub.

This library provides support for Wink in Home Assistant!

To install

pip3 install python-wink

Get developer credentials

  1. Vist https://developer.wink.com/login
  2. Crate an account and request your credentials. (Approval can take several days)
  3. Enter in a redirect URL to point at your application.
  4. Plug in your details into the test script below.

Example usage

Print all light names and state, and toggle their states.

import pywink

print("Please vist the following URL to authenticate.")
print(pywink.get_authorization_url("YOUR_CLIENT_ID", "YOUR_REDIRECT_URL"))
code = input("Enter code from URL:")
auth = pywink.request_token(code, "YOUR_CLIENT_SECRET")
pywink.set_wink_credentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET",
                                         auth.get("access_token"), auth.get("refresh_token"))

lights = pywink.get_light_bulbs()
for light in lights:
    print("Name: " + light.name())
    print("State: " + light.state())
    light.set_state(not light.state())

python-wink's People

Contributors

balloob avatar bradsk88 avatar geekofweek avatar gitter-badger avatar kpine avatar miniconfig avatar philk avatar piotrgg avatar turnrye avatar vickyg3 avatar xrolfex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-wink's Issues

Request to add Ring Doorbell for motion and button pressed

Is that possible to add support for Ring Doorbell? Json data from Wink shows details about this device I can provide Json if need and can do testing when needed. Once added would like to see this Wink component in Home Assistant as well.
Appreciate your efforts.

Request to add support for Rachio sprinkler

Rachio sprinkler system gets connected to Wink hub and provides status and control watering of configured zones.
Here is the JSON to see what information it provides. I didn't find much useful information though may be few more calls we may have to make to get more information?

{
  "object_type": "sprinkler",
  "object_id": "xxxx",
  "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "icon_id": null,
  "icon_code": null,
  "desired_state": {
    "powered": true
  },
  "last_reading": {
    "connection": true,
    "connection_updated_at": 1477933016.6407745,
    "powered": true,
    "powered_updated_at": 1466562190.6761053,
    "desired_powered": null,
    "desired_powered_updated_at": null
  },
  "subscription": {
    "pubnub": {
      "subscribe_key": "sub-x-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "channel": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|sprinkler-xxxx|user-xxxxxx"
    }
  },
  "sprinkler_id": "xxxx",
  "name": "xxxx",
  "locale": "en_us",
  "units": {},
  "created_at": 1463026663,
  "hidden_at": null,
  "capabilities": {
    "fields": [
      {
        "type": "boolean",
        "field": "connection",
        "mutability": "read-only"
      },
      {
        "type": "boolean",
        "field": "powered",
        "mutability": "read-write"
      }
    ]
  },
  "manufacturer_device_model": "rachio_iro_v2",
  "manufacturer_device_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "device_manufacturer": "rachio",
  "model_name": "Iro",
  "upc_id": "xxx",
  "upc_code": "wifi_rachio_v2",
  "linked_service_id": "xxxxxx",
  "lat_lng": [
    null,
    null
  ],
  "location": "",
  "zones": []
}

Kidde Smoke detectors do not have battery level.

I am not sure when it started but I noticed the Kidde Smoke detectors do not show battery level in HASS anymore but they used to.

I can still see the info in the wink Json response.

Thanks as always.

Local Control

What is the status of being able to use the local control api?

Spotters read only as open / closed

I have a pair of spotters in my Wink system when using Home assistant they only show as open/ closed normally closed.
haspotters
do I have something set wrong or is this an issue with the python-Wink?

BadStatusLine from requests made to the Wink API

I occasionally see the below error during startup of Home-Assistant. I have included two different runs each got the same error, but at a different point during startup. The error happens when the Wink API is queried. Right after these two attempts the third was successful.

Not sure if this is fixable here, if we are doing what we should already and blowing up? Is this an issue that requests should handle better? Are there any other libraries that could be used besides requests that may work better/not receive this error?

I probably see this once in maybe 20 reboots? Although in this case it happened three times in a row.

This is during startup of Home-Assistant (nothing from wink was added)

17-01-02 17:17:37 homeassistant.bootstrap: Error during setup of component wink
Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/util/retry.py", line 334, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine("''",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/bootstrap.py", line 151, in _async_setup_component
    None, component.setup, hass, config)
  File "/usr/lib/python3.4/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/components/wink.py", line 82, in setup
    pywink.get_subscription_key(),
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 190, in get_subscription_key
    response_dict = wink_api_fetch()
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 204, in wink_api_fetch
    response = requests.get(arequest_url, headers=API_HEADERS)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))

This is from a different startup (everything but switches and locks were added)

17-01-02 17:26:13 homeassistant.components.lock: Error while setting up platform wink
Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/util/retry.py", line 334, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine("''",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/helpers/entity_component.py", line 150, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.4/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/components/lock/wink.py", line 18, in setup_platform
    add_devices(WinkLockDevice(lock, hass) for lock in pywink.get_locks())
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 146, in get_locks
    return get_devices(device_types.LOCK)
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 215, in get_devices
    response_dict = wink_api_fetch()
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 204, in wink_api_fetch
    response = requests.get(arequest_url, headers=API_HEADERS)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
17-01-02 17:26:14 homeassistant.components.switch: Error while setting up platform wink
Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/util/retry.py", line 334, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine("''",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/helpers/entity_component.py", line 150, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.4/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result

    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/components/switch/wink.py", line 20, in setup_platform
    for switch in pywink.get_powerstrip_outlets():
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 162, in get_powerstrip_outlets
    return get_devices(device_types.POWER_STRIP)
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 215, in get_devices
    response_dict = wink_api_fetch()
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 204, in wink_api_fetch
    response = requests.get(arequest_url, headers=API_HEADERS)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
17-01-02 17:26:17 homeassistant.components.binary_sensor: Error while setting up platform wink
Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/util/retry.py", line 334, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 391, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 387, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1227, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 386, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 356, in _read_status
    raise BadStatusLine(line)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine("''",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/helpers/entity_component.py", line 150, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.4/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/homeassistant-0.36.0.dev0-py3.4.egg/homeassistant/components/binary_sensor/wink.py", line 43, in setup_platform
    for hub in pywink.get_hubs():
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 186, in get_hubs
    return get_devices(device_types.HUB)
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 215, in get_devices
    response_dict = wink_api_fetch()
  File "/home/w1ll1am/.virtualenvs/hass_dev/config/deps/pywink/api.py", line 204, in wink_api_fetch
    response = requests.get(arequest_url, headers=API_HEADERS)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/w1ll1am/.virtualenvs/hass_dev/lib/python3.4/site-packages/requests-2.12.4-py3.4.egg/requests/adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))

PIR motion sensors aren't detected

Wink updated the API to return temperature form the PIR motion sensors. This broke the motion sensing of the sensor, and it looks like temperature isn't properly detected either. Tests fail when using the new json.

{  
   "last_event":{  
      "brightness_occurred_at":null,
      "loudness_occurred_at":null,
      "vibration_occurred_at":null
   },
   "uuid":"4c93936f-840e-40fc1232184-ee3583408d71",
   "desired_state":{  

   },
   "last_reading":{  
      "motion":false,
      "motion_updated_at":1473870334.9673228,
      "battery":1,
      "battery_updated_at":1473870334.9673228,
      "tamper_detected":null,
      "tamper_detected_updated_at":null,
      "temperature":21.666666666666668,
      "temperature_updated_at":1473870334.9673228,
      "motion_true":"N/A",
      "motion_true_updated_at":1473870129.6595004,
      "tamper_detected_true":null,
      "tamper_detected_true_updated_at":null,
      "connection":true,
      "connection_updated_at":1473870334.9673228,
      "agent_session_id":null,
      "agent_session_id_updated_at":null,
      "motion_changed_at":1473870334.9673228,
      "motion_true_changed_at":1473870129.6595004,
      "temperature_changed_at":1473862426.2809358
   },
   "subscription":{  
      "pubnub":{  
         "subscribe_key":"sub-c-f7-11e3-a5e8-02ee2ddab7fe",
         "channel":"b60201ecf033b6e7181|sensor_pod-152619|user-377857"
      }
   },
   "sensor_pod_id":"151234",
   "name":"Living room",
   "locale":"en_us",
   "units":{  

   },
   "created_at":1452810755,
   "hidden_at":null,
   "capabilities":{  
      "fields":[  
         {  
            "type":"boolean",
            "field":"motion",
            "mutability":"read-only"
         },
         {  
            "type":"percentage",
            "field":"battery",
            "mutability":"read-only"
         },
         {  
            "type":"boolean",
            "field":"tamper_detected",
            "mutability":"read-only"
         },
         {  
            "type":"float",
            "field":"temperature",
            "mutability":"read-only"
         }
      ]
   },
   "triggers":[  

   ],
   "manufacturer_device_model":"linear_wapirz_1",
   "manufacturer_device_id":null,
   "device_manufacturer":"linear",
   "model_name":"Z-Wave Passive Infrared (PIR) Sensor",
   "upc_id":"207",
   "upc_code":"093863125102",
   "gang_id":null,
   "hub_id":"302528",
   "local_id":"6",
   "radio_type":"zwave",
   "linked_service_id":null,
   "lat_lng":[  
      12.345678,
      -89.765432
   ],
   "location":""
}

Hampton Bay Flush Mount LED returning False from supports_temperature()

Just picked up this light yesterday and the temperature adjustment isn't available in Home-Assistant. Looks the the API response isn't what python wink is expecting for the supports_temperature() method. There is no "color_changeable" in the response. Based on the API it looks like the only guaranteed way of checking this would be with the color_model? I'll try to work on a fix for this.

color_model (string) one of: "xy", "hsb", "color_temperature", or "rgb"

{
         "uuid":"49ce6c1a-5c45-427b-94e8-acd20a212345",
         "desired_state":{
            "powered":false,
            "brightness":1.0,
            "color_model":"color_temperature",
            "color_temperature":2703
         },
         "last_reading":{
            "connection":true,
            "connection_updated_at":1471227915.4186487,
            "powered":false,
            "powered_updated_at":1471227915.4186487,
            "brightness":1.0,
            "brightness_updated_at":1471227915.4186487,
            "color_model":"color_temperature",
            "color_model_updated_at":1471227915.4186487,
            "color_temperature":2703,
            "color_temperature_updated_at":1471227915.4186487,
            "firmware_version":"0.0b00 / 0.0b10",
            "firmware_version_updated_at":1471227915.4186487,
            "firmware_date_code":null,
            "firmware_date_code_updated_at":null,
            "desired_powered_updated_at":1471227914.4598782,
            "desired_brightness_updated_at":1471227914.4598782,
            "desired_color_model_updated_at":1471228068.9510634,
            "desired_color_temperature_updated_at":1471228068.9510634,
            "powered_changed_at":1471227914.3858144,
            "brightness_changed_at":1471218071.9009795,
            "connection_changed_at":1471217520.6569426,
            "firmware_version_changed_at":1471217520.944115,
            "color_model_changed_at":1471217520.944115,
            "color_temperature_changed_at":1471218144.7531166,
            "desired_powered_changed_at":1471227914.4598782,
            "desired_brightness_changed_at":1471227914.4598782,
            "desired_color_temperature_changed_at":1471218271.9440646,
            "desired_color_model_changed_at":1471217693.4812942
         },
         "subscription":{
            "pubnub":{
               "subscribe_key":"",
               "channel":""
            }
         },
         "light_bulb_id":"1928312",
         "name":"Kitchen Sink Light",
         "locale":"en_us",
         "units":{

         },
         "created_at":1471217520,
         "hidden_at":null,
         "capabilities":{
            "fields":[
               {
                  "type":"boolean",
                  "field":"connection",
                  "mutability":"read-only"
               },
               {
                  "type":"boolean",
                  "field":"powered",
                  "mutability":"read-write"
               },
               {
                  "type":"percentage",
                  "field":"brightness",
                  "mutability":"read-write"
               },
               {
                  "type":"string",
                  "field":"color_model",
                  "choices":[
                     "color_temperature"
                  ],
                  "mutability":"read-write",
                  "legacy_type":"colorModel"
               },
               {
                  "type":"integer",
                  "field":"color_temperature",
                  "range":[
                     2700,
                     5000
                  ],
                  "mutability":"read-write"
               }
            ]
         },
         "triggers":[

         ],
         "manufacturer_device_model":"hampton_bay_54668161",
         "manufacturer_device_id":null,
         "device_manufacturer":"hampton_bay",
         "model_name":"12\" Flush Mount",
         "upc_id":"501",
         "upc_code":"eti_flushmount",
         "gang_id":null,
         "hub_id":"302528",
         "local_id":"25",
         "radio_type":"zigbee",
         "linked_service_id":null,
         "lat_lng":[
            12.3456,
            -98.7654
         ],
         "location":"",
         "order":0
      }

Wink API subscribe loop error: 'Remote end closed connection without response'

Hopefully Wink software engineers will either improve their new internal PubNub-like service to properly close connections or document what changes should be made in clients. If not, at some point an effort should be made to see if there is anything that can be done in python-wink to reduce or eliminate this error that fills the log unless suppressed.

Searching for this error (not specific to Wink) turns up several recommendations that might merit further investigation...

Stackoverflow suggests an "end_Headers()" call can solve the issue for the simple example cited.

Adding a 1 second delay seems to have solved this error for a Django server issue mentioned in Github. Maybe consider making this a configurable value (in milliseconds). Wink probably has a long way to go to catch up to PubNub's efficiency and their responses could be just too slow right now.

Another reference mentioned urllib3 version. Maybe consider updating urllib3? My HASSIO has v1.24.2 installed, but the latest version is v1.25.2

Garage Door control has stopped functioning


Mar 11 06:26:37 raspberrypi hass[980]: INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1982410576-10>
Mar 11 06:26:37 raspberrypi hass[980]: INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1982410576-9>
Mar 11 06:26:37 raspberrypi hass[980]: INFO:homeassistant.components.http:"POST /api/services/homeassistant/turn_on HTTP/1.1" 200 -
Mar 11 06:26:54 raspberrypi hass[980]: INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=open, service_data=entity_id=garage_door.garage_door, domain=garage_door, service_call_id=1982410576-11>
Mar 11 06:26:54 raspberrypi hass[980]: ERROR:homeassistant.core:BusHandler:Exception doing job
Mar 11 06:26:54 raspberrypi hass[980]: Traceback (most recent call last):
Mar 11 06:26:54 raspberrypi hass[980]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 789, in job_handler
Mar 11 06:26:54 raspberrypi hass[980]: func(arg)
Mar 11 06:26:54 raspberrypi hass[980]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 643, in _execute_service
Mar 11 06:26:54 raspberrypi hass[980]: service(call)
Mar 11 06:26:54 raspberrypi hass[980]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 510, in __call__
Mar 11 06:26:54 raspberrypi hass[980]: self.func(call)
Mar 11 06:26:54 raspberrypi hass[980]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/garage_door/__init__.py", line 68, in handle_garage_door_service
Mar 11 06:26:54 raspberrypi hass[980]: item.open_door()
Mar 11 06:26:54 raspberrypi hass[980]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/garage_door/wink.py", line 65, in open_door
Mar 11 06:26:54 raspberrypi hass[980]: self.wink.set_state(1)
Mar 11 06:26:54 raspberrypi hass[980]: File "/home/pi/.homeassistant/lib/pywink/devices/standard.py", line 382, in set_state
Mar 11 06:26:54 raspberrypi hass[980]: response = self.api_interface.set_device_state(self, values)
Mar 11 06:26:54 raspberrypi hass[980]: File "/home/pi/.homeassistant/lib/pywink/api.py", line 24, in set_device_state
Mar 11 06:26:54 raspberrypi hass[980]: _id = device.device_id()
Mar 11 06:26:54 raspberrypi hass[980]: File "/home/pi/.homeassistant/lib/pywink/devices/standard.py", line 374, in device_id
Mar 11 06:26:54 raspberrypi hass[980]: return self.json_state.get('garage_door_id', self.name())
Mar 11 06:26:54 raspberrypi hass[980]: AttributeError: 'NoneType' object has no attribute 'get'

Excessive API calls?

This is not so much an issue but more an FYI.

Home Assistant got an e-mail from a site reliability engineer at Wink about excessive API calls:

We've observed 5 Wink users that have added the Home-Assistant.io integration to their account making excessive calls - roughly 8k every 10mins to the Wink API.

I am not sure if this was because of the way Home Assistant used the API or that a bug sneaked in that causes the extra calls. From my knowledge of the Home Assistant integration, this high amount of calls would be highly unlikely. @w1ll1am23 has migrated Home Assistant to use pubnub so we should drop usage significantly but I just thought to notify you that there might be an issue lingering somewhere.

Add egg age to eggminder sensor

Would there be a way to add the egg age to the egg minder implementation?

Could each "egg" me an attribute of the egg minder or its own sensor?

JSON to follow for egg minder.

{
  "last_reading": {
    "connection": true,
    "connection_updated_at": 1548533136.8051031,
    "battery": 0.83,
    "battery_updated_at": 1548533462.6337011,
    "inventory": 10,
    "inventory_updated_at": 1548533267.7786317,
    "age": 1548533247,
    "age_updated_at": 1548533267.778636,
    "freshness_remaining": 2419180,
    "freshness_remaining_updated_at": 1548533267.7786391,
    "next_trigger_at": null,
    "next_trigger_at_updated_at": null,
    "egg_1_timestamp": 1548533247.0,
    "egg_1_timestamp_updated_at": 1548533462.6005039,
    "egg_2_timestamp": 1548533254.0,
    "egg_2_timestamp_updated_at": 1548533462.6005039,
    "egg_3_timestamp": 1548533260.0,
    "egg_3_timestamp_updated_at": 1548533462.6005039,
    "egg_4_timestamp": 1548533266.0,
    "egg_4_timestamp_updated_at": 1548533462.6005039,
    "egg_5_timestamp": 1548533304.0,
    "egg_5_timestamp_updated_at": 1548533462.6005039,
    "egg_6_timestamp": 1548533281.0,
    "egg_6_timestamp_updated_at": 1548533462.6005039,
    "egg_7_timestamp": 1548533286.0,
    "egg_7_timestamp_updated_at": 1548533462.6005039,
    "egg_8_timestamp": 1548533257.0,
    "egg_8_timestamp_updated_at": 1548533462.6005039,
    "egg_9_timestamp": 1548533261.0,
    "egg_9_timestamp_updated_at": 1548533462.6005039,
    "egg_10_timestamp": 1548533264.0,
    "egg_10_timestamp_updated_at": 1548533462.6005039,
    "egg_11_timestamp": 1548533269.0,
    "egg_11_timestamp_updated_at": 1548533462.6005039,
    "egg_12_timestamp": 1548533277.0,
    "egg_12_timestamp_updated_at": 1548533462.6005039,
    "egg_13_timestamp": 1548533284.0,
    "egg_13_timestamp_updated_at": 1548533462.6005039,
    "egg_14_timestamp": 1548533289.0,
    "egg_14_timestamp_updated_at": 1548533462.6005039,
    "connection_changed_at": 1548533136.8051031,
    "egg_1_timestamp_changed_at": 1548533248.5244327,
    "egg_2_timestamp_changed_at": 1548533254.0001071,
    "egg_3_timestamp_changed_at": 1548533259.4407098,
    "egg_4_timestamp_changed_at": 1548533264.8369234,
    "egg_5_timestamp_changed_at": 1548533301.3719635,
    "egg_6_timestamp_changed_at": 1548533282.0776887,
    "egg_7_timestamp_changed_at": 1548533289.3529837,
    "egg_8_timestamp_changed_at": 1548533251.3175113,
    "egg_9_timestamp_changed_at": 1548533254.0001071,
    "egg_10_timestamp_changed_at": 1548533257.1119959,
    "egg_11_timestamp_changed_at": 1548533260.8004711,
    "egg_12_timestamp_changed_at": 1548533267.5767336,
    "egg_13_timestamp_changed_at": 1548533272.9687474,
    "egg_14_timestamp_changed_at": 1548533282.0776887,
    "battery_changed_at": 1548533138.0068018
  },
  "eggs": [
    1548533247.0,
    1548533254.0,
    1548533260.0,
    1548533266.0,
    1548533304.0,
    1548533281.0,
    1548533286.0,
    1548533257.0,
    1548533261.0,
    1548533264.0,
    1548533269.0,
    1548533277.0,
    1548533284.0,
    1548533289.0
  ],
  "freshness_period": 2419200,
  "object_type": "eggtray",
  "object_id": "162564",
  "uuid": "f4a5db99-abc6-4e96-a807-d570721e9a7c",
  "created_at": 1548533136,
  "updated_at": 1548533143,
  "icon_id": null,
  "icon_code": null,
  "subscription": {
    "pubnub": {
      "subscribe_key": "subb7fe",
      "channel": "7551e17",
      "origin": null
    }
  },
  "eggtray_id": "162564",
  "name": "Egg Minder1",
  "locale": "en_us",
  "units": {},
  "hidden_at": null,
  "capabilities": {
    "supports_electric_imp": true,
    "needs_wifi_network_list": true
  },
  "triggers": [],
  "device_manufacturer": "quirky_ge",
  "model_name": "Egg Minder",
  "upc_id": "528",
  "upc_code": "quirky_ge_egg_minder",
  "primary_upc_code": "quirky_ge_egg_minder",
  "lat_lng": [
    ,
    
  ],
  "location": "",
  "mac_address": "",
  "serial": ""
}

Question: Can local_control be set to true with API Key Based Auth?

Hello,

I'm a downstream user of pywink via the wink: integration for Home Assistant. I've had this integration setup for a while but due to the constant issues with Wink (most recently the expired wildcard cert on api.wink.com) I want to switch this device to be local_control only so that it will just be my operator for ZWave, Zigbee and Lutron devices.

https://www.home-assistant.io/integrations/wink/ says that No settings are required in the configuration.yaml other than wink: but it's unclear if that means that you can use the API key based auth with https://www.home-assistant.io/integrations/wink/#local_control set to true.

Can you?

Thanks!

last_reading missing from pubnub responses

Noticed this error today in my Home-Assistant logs. It looks like pubnub is returning invalid JSON responses occasionally. Wondering how we should handle this? Is there something that should be added to the pubnub_update method to validate the JSON is good? Maybe a check for last_reading and if it is bad don't update the state?

Nov 03 21:46:03 hass hass[18437]: self.wink.pubnub_update(json.loads(message))
Nov 03 21:46:03 hass hass[18437]: File "/home/pi/.virtualenvs/hass_dev/config/deps/pywink/devices/sensors.py", line 105, in pubnub_update
Nov 03 21:46:03 hass hass[18437]: hum = json_response["last_reading"]["humidity"] * 100
Nov 03 21:46:03 hass hass[18437]: KeyError: 'last_reading'

Motion sensors never trigger

I have numerous motion sensors on my winkhub; they show up in HA but they remain in state "closed" regardless of the actual sensor's state.

Note that the raw sensor's data from the wink API is as follows:

"last_reading":{  
            "brightness_true":"N/A",
            "brightness_true_updated_at":1439321444.5886877,
            "loudness_true":"N/A",
            "loudness_true_updated_at":1439321444.5886877,
            "vibration_true":"N/A",
            "vibration_true_updated_at":1439321444.5886877,
            "motion_true":"N/A",
            "motion_true_updated_at":1447023687.4216366,
            "tamper_detected_true":"N/A",
            "tamper_detected_true_updated_at":1439321444.5886877,
            "liquid_detected_true":"N/A",
            "liquid_detected_true_updated_at":1439321444.5886877,
            "connection":true,
            "connection_updated_at":1447023939.8871322,
            "agent_session_id":"TRUE",
            "agent_session_id_updated_at":1439567066.9356022,
            "motion":false,
            "motion_updated_at":1447023939.8871322,
            "motion_changed_at":1447023939.8871322,
            "motion_true_changed_at":1447023687.4216366,
            "connection_changed_at":1446390843.0051572
         },

Compared to that of a door sensor (which works properly today):

"last_reading":{  
            "brightness_true":null,
            "brightness_true_updated_at":null,
            "loudness_true":null,
            "loudness_true_updated_at":null,
            "vibration_true":null,
            "vibration_true_updated_at":null,
            "motion_true":null,
            "motion_true_updated_at":null,
            "tamper_detected_true":null,
            "tamper_detected_true_updated_at":null,
            "liquid_detected_true":null,
            "liquid_detected_true_updated_at":null,
            "connection":true,
            "connection_updated_at":1447020896.8965771,
            "agent_session_id":null,
            "agent_session_id_updated_at":null,
            "opened":false,
            "opened_updated_at":1447020896.8965771,
            "connection_changed_at":1446931274.0103889,
            "opened_changed_at":1447020896.8965771
         },

I'll implement and submit a pull request.

Small clean up item

Minor clean up item. In line 209 of init.py. This is the file directory src/pywink/devices/standard/

There is an 'r' before the 3 ". Not sure that this affects code, but it does show up in code editors.

r""" represents a wink.py garage door

Scenes, Robots, and Thermostats are incompatible with "device" interface

The "Device" interface implies that an API entity will have the following units which thermostats, robots, and scenes do not reliably have:

  • unit (for sensor reading)
  • state (particularly for Scenes)
  • device manufacturer (We may be able to fall back to "Wink". for this)
  • device model name

It may be possible to extract a more simplified interface for these objects.

Add Kidde Smoke alarm support.

Would It be possible to add support for Kidde Smoke alarms and CO detector? Below is a sample JSON for the detectors.

The device Response looks like this. Please let me know if there are any more details needed.

The important fields would be Smoke Detected, CO Detected and Battery level.

{
"object_type":"smoke_detector",
"object_id":"REMOVED",
"uuid":"54feac93-327e-4f04-a8ba-500c88e95245",
"icon_id":null,
"icon_code":null,
"last_reading":{
"connection":true,
"connection_updated_at":1462586187.9383092,
"battery":0.9,
"battery_updated_at":1462586188.4449866,
"co_detected":false,
"co_detected_updated_at":1462586188.4449866,
"smoke_detected":false,
"smoke_detected_updated_at":1471015253.2221863,
"test_activated":false,
"test_activated_updated_at":1462997176.8458738
},
"subscription":{
"pubnub":{
"subscribe_key":"REMOVED",
"channel":"Removed|smoke_detector-REMOVED|user-REMOVED"
}
},
"smoke_detector_id":"REMOVED",
"name":"Hallway Smoke Detector",
"locale":"en_us",
"units":{

},
"created_at":1462586187,
"hidden_at":null,
"capabilities":{

},
"manufacturer_device_model":"kidde_smoke_alarm",
"manufacturer_device_id":null,
"device_manufacturer":"kidde",
"model_name":"Smoke Alarm",
"upc_id":"524",
"upc_code":"kidde_smoke_alarm",
"hub_id":REMOVED",
"local_id":null,
"radio_type":"kidde",
"linked_service_id":null,
"lat_lng":[
39.00000,
-77.00000
],
"location":"REMOVED"
}`

Wink Thermostats

I see there have a been a few things added recently (garage door, egg minder & additional spotter features) I was hoping to be able add thermostat support, I am not a python programmer so I was making a poor attempt at trying to add it but I noticed you an update so thought I would at least ask :)

Wink.py/fan.py errors adding GE in-wall fan (update #105)

I have two ceiling fans paired with Wink using the GE in-wall fan control. Both were working in Hassio 70.1 (as light.xxxxx entities), but upon updating to 72.1 today, only one is working (now as fan.xxxx). (per Wink update #105 @vickyg3)

Here is the error which indicates something amiss with reading brightness/fan speed. The fan that failed to be integrated properly was currently at or near zero so as to get the lowest possible speed.

`2018-06-27 14:25:18 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved

Traceback (most recent call last):

File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 326, in _async_add_entity
await entity.async_update_ha_state()

File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 215, in async_update_ha_state
attr = self.state_attributes or {}

File "/usr/lib/python3.6/site-packages/homeassistant/components/fan/init.py", line 315, in state_attributes
if not hasattr(self, prop):

File "/usr/lib/python3.6/site-packages/homeassistant/components/fan/wink.py", line 66, in speed
current_wink_speed = self.wink.current_fan_speed()

File "/usr/lib/python3.6/site-packages/pywink/devices/fan.py", line 129, in current_fan_speed
return self._to_speed[self._last_reading.get('brightness', 0.33)]
KeyError: 0.0`


Note: group.all_fans lists both fans ( fan.bedroom_ceiling_fan, fan.den_ceiling_fan)
but "fan.den_ceiling_fan" did not exist as an entity when I first looked into this problem.

UPDATE:
I have just now set this fan to full speed via the Wink interface, and lo and behold, fan.den_ceiling_fan is now listed as an entity and shows up on the dashboard! It appears that the errors listed above have also stopped.

Exposing groups.

Is there any interest in exposing groups of lights to HA?

I could see some use cases to avoid multiple calls to turn a wink group of lights off.

But I could also see where it would create issues if we have HA groups and wink groups.

states broken in HA 0.18 and python-wink 0.7.4

No longer receiving correct state for lights (and some other devices) when devices are toggled outside of HA. For example, if turn a light on/off from the switch, the state change isn't registered by HA, leaving it in the previous state until manipulated again by HA.

This is some of the errors from my logs.

16-04-20 23:07:12 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\core.py", line 801, in job_handler
    func(arg)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\event.py", line 176, in pattern_time_change_listener
    action(now)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\entity_component.py", line 169, in _update_entity_states
    entity.update_ha_state(True)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\entity.py", line 145, in update_ha_state
    self.update()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\components\wink.py", line 102, in update
    self.wink.update_state()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\pywink\devices\base.py", line 53, in update_state
    response = self.api_interface.get_device_state(self)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\pywink\api.py", line 42, in get_device_state
    return arequest.json()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\requests\models.py", line 808, in json
    return complexjson.loads(self.text, **kwargs)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
16-04-21 00:02:30 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\core.py", line 801, in job_handler
    func(arg)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\event.py", line 176, in pattern_time_change_listener
    action(now)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\entity_component.py", line 169, in _update_entity_states
    entity.update_ha_state(True)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\helpers\entity.py", line 145, in update_ha_state
    self.update()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\homeassistant\components\lock\wink.py", line 52, in update
    self.wink.update_state()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\pywink\devices\base.py", line 53, in update_state
    response = self.api_interface.get_device_state(self)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\pywink\api.py", line 42, in get_device_state
    return arequest.json()
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\requests\models.py", line 808, in json
    return complexjson.loads(self.text, **kwargs)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
16-04-21 02:03:25 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
  File "c:\users\brendan\appdata\local\programs\python\python35\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 376, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

Wink App updates

Wink App now allows Local control does this update change the way Python-wink will work?

Access token not automatically refreshed

Noticed my wink components weren't being updated in Home Assistant. I saw some wink.py exceptions in the logs, but ignored them. But after a restart saw this error:

dietpi@hasspi:/home/homeassistant/.homeassistant$ cat home-assistant.log
2018-02-15 23:58:18 ERROR (MainThread) [homeassistant.setup] Error during setup of component wink
Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/setup.py", line 199, in_async_setup_component
    component.setup, hass, processed_config)
  File "/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/components/wink/__init__.py", line 312, in setup
    pywink.get_subscription_key())
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/pywink/api.py", line 577, in get_subscription_key
    response_dict = wink_api_fetch()
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/pywink/api.py", line 598, in wink_api_fetch
    raise WinkAPIException("401 Response from Wink API.  Maybe Bearer token is expired?")
pywink.api.WinkAPIException: 401 Response from Wink API.  Maybe Bearer token is expired?

Looked around in the python-wink source code and saw some refresh code had been added in the past. I was able to refresh the token via the API and update my .wink.conf file.

>>> pywink.set_wink_credentials(client_id, client_secret, access_token=access_token, refresh_token=refresh_token)
>>> lights = pywink.get_light_bulbs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/homeassistant/.pyenv/versions/homeassistant-3.6.3/lib/python3.6/site-packages/pywink/api.py", line 445, in get_light_bulbs
    return get_devices(device_types.LIGHT_BULB)
  File "/home/homeassistant/.pyenv/versions/homeassistant-3.6.3/lib/python3.6/site-packages/pywink/api.py", line 610, in get_devices
    ALL_DEVICES = wink_api_fetch(end_point)
  File "/home/homeassistant/.pyenv/versions/homeassistant-3.6.3/lib/python3.6/site-packages/pywink/api.py", line 598, in wink_api_fetch
    raise WinkAPIException("401 Response from Wink API.  Maybe Bearer token is expired?")
pywink.api.WinkAPIException: 401 Response from Wink API.  Maybe Bearer token is expired?
>>> pywink.refresh_access_token()
'redacted'
>>> lights = pywink.get_light_bulbs()
>>>

Maybe this is an issue/feature that should be solved in Home Assistant instead, but I thought I'd try here first.

OAuth issue

I might be using this in an atypical way so it could be the source of my problem. I'm not integrating with HA, only running the sample code from the cli. The sample code requires copying and pasting a URL into a browser, logging into the Wink account and then copying the returned code (only) out of the response URL. Does anyone have a sample where the credentials can be fed in through Python and the response code automatically parsed?

Osram Lightiify

Noting this here as well this is an enhancement request.
the code below is a pull from my list all devices from the API.
yes I named my color changing bulb the bat signal

{
      "uuid": "238539e2-1ad6-44ba-bc53-33c684c36e1d",
      "desired_state": {
        "powered": false,
        "brightness": 1,
        "color_model": "hsb",
        "hue": 0.35,
        "saturation": 1,
        "color_temperature": 1901
      },
      "last_reading": {
        "connection": true,
        "connection_updated_at": 1458628651.862995,
        "powered": false,
        "powered_updated_at": 1458628651.862995,
        "brightness": 1,
        "brightness_updated_at": 1458628651.862995,
        "color_model": "hsb",
        "color_model_updated_at": 1458628651.862995,
        "hue": 0.35,
        "hue_updated_at": 1458628651.862995,
        "saturation": 1,
        "saturation_updated_at": 1458628651.862995,
        "color_temperature": 1901,
        "color_temperature_updated_at": 1458628651.862995,
        "firmware_version": "0.1b02 / 0.3b22",
        "firmware_version_updated_at": 1458628651.862995,
        "firmware_date_code": "20150929N****",
        "firmware_date_code_updated_at": 1458628651.862995,
        "desired_powered_updated_at": 1458628650.8619466,
        "desired_brightness_updated_at": 1458628820.0301423,
        "desired_color_model_updated_at": 1458628820.0301423,
        "desired_hue_updated_at": 1458628820.0301423,
        "desired_saturation_updated_at": 1458628820.0301423,
        "desired_color_temperature_updated_at": 1458628820.0301423,
        "powered_changed_at": 1458628650.8134031,
        "brightness_changed_at": 1458122238.7788615,
        "connection_changed_at": 1457517588.4372394,
        "desired_powered_changed_at": 1458628650.8619466,
        "desired_brightness_changed_at": 1458628381.8566465,
        "firmware_date_code_changed_at": 1457521561.0603704,
        "color_model_changed_at": 1457521797.6389458,
        "hue_changed_at": 1457595786.5472758,
        "saturation_changed_at": 1457595782.71269,
        "color_temperature_changed_at": 1457521786.911106,
        "firmware_version_changed_at": 1457521561.0603704,
        "desired_color_model_changed_at": 1458620834.569744,
        "desired_hue_changed_at": 1457595786.605935,
        "desired_saturation_changed_at": 1457595782.8273423,
        "desired_color_temperature_changed_at": 1457521921.4747667
      },
      "light_bulb_id": "1515274",
      "name": "Bat Signal",
      "locale": "en_us",
      "units": {},
      "created_at": 1457517586,
      "hidden_at": null,
      "capabilities": {
        "fields": [
          {
            "field": "connection",
            "type": "boolean",
            "mutability": "read-only"
          },
          {
            "field": "powered",
            "type": "boolean",
            "mutability": "read-write"
          },
          {
            "field": "brightness",
            "type": "percentage",
            "mutability": "read-write"
          },
          {
            "field": "color_model",
            "type": "string",
            "choices": [
              "rgb",
              "hsb",
              "color_temperature"
            ]
          },
          {
            "field": "hue",
            "type": "percentage",
            "mutability": "read-write"
          },
          {
            "field": "saturation",
            "type": "percentage",
            "mutability": "read-write"
          },
          {
            "field": "color_temperature",
            "range": [
              1900,
              6500
            ],
            "type": "integer",
            "mutability": "read-write"
          }
        ],
        "color_changeable": true
      },
      "triggers": [],
      "manufacturer_device_model": "sylvania_sylvania_rgbw",
      "manufacturer_device_id": null,
      "device_manufacturer": "sylvania",
      "model_name": "Lightify RGBW Bulb",
      "upc_id": "509",
      "upc_code": "4613573703",
      "gang_id": null,
      "hub_id": "381678",
      "local_id": "37",
      "radio_type": "zigbee",
      "linked_service_id": null,
      "lat_lng": [
        null,
        null
      ],
      "location": "",
      "order": 0
    },

Nimbus support

The API does not currently support Nimbus devices. It is a legacy device, but can be used to display a wide variety of information. I'm using it right now to display server stats using a legacy python library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.