wink-js
wink-js is a library that allows one to access wink API resources from a user perspective. Its target is to simplify integrations with wink backend and hopefully allow more people to create fun applications for your wink connected home.
This is not an official library from wink, please do not contact them for support, however you can always open bugs against this project on github
official wink api documentaton URI http://docs.wink.apiary.io/
Devices with helpers
- Lights
- Thermostats
- Eggminder
Devices can be used via raw getter and setter device_group()
Synopsis
var wink = ; wink;
Methods
.init()
Initialize wink framework (performs login)
wink;
- obj
- conf: path to configuraiton file with settings below (optional)
- client_id: Client id issued by wink support
- client_secret: Client secret issued by wink support
- username: username(email) used to login to wink app
- password: password used to login to wink app
wink; wink; /*# config.json:{ "client_id": "CLIENT_ID_HERE", "client_secret": "CLIENT_SECRET_HERE", "username": "WINK_EMAIL_HERE", "password": "WINK_PASSWORD_HERE"}*/
response:
// callback(data) "data": "access_token": "xxx" "refresh_token": "xxx" "token_type": "bearer" "token_endpoint": "https://winkapi.quirky.com/oauth2/token" "errors": "pagination": {} "access_token": "xxx" "refresh_token": "xxx" "token_type": "bearer" "token_endpoint": "https://winkapi.quirky.com/oauth2/token"
.user()
Perform operations on behalf of a user
wink.user(userId);
- userId: defaults to "me" (logged in user)
.get(callback)
Retrieve user information
wink;
response:
// callback(data) "data": "user_id": "1234" "first_name": "John" "last_name": "Doe" "email": "myemail@example.com" "locale": "en_us" "units": {} "tos_accepted": true "confirmed": true "last_reading": "units": null "units_updated_at": null "desired_units": null "desired_units_updated_at": null "errors": "pagination": {}
.linked_services
Linked wink services namespace
.get(callback)
Retrieve list of linked services
winklinked_services;
response:
// callback(data) "data": "errors": "pagination": "count": 0
.devices(device_type?, callback)
Retrieve list of devices associated with account, and inflates each device into its respective object with availabe actions, for more details on available actions, see Models section
wink;wink;
- device_type (optional): defaulted to "wink_devices"
response:
// callback(data) "data": "hub_id": "xxx" "name": "Hub" "locale": "en_us" "units": {} "created_at": 1425689198 "hidden_at": null "capabilities": "oauth2_clients": "wink_hub" "triggers": "desired_state": "pairing_mode": null "manufacturer_device_model": "wink_hub" "manufacturer_device_id": null "device_manufacturer": "wink" "model_name": "Hub" "upc_id": "15" "last_reading": "connection": true "connection_updated_at": 14295002444901872 "agent_session_id": "xxx" "agent_session_id_updated_at": 1429500216915741 "remote_pairable": true "remote_pairable_updated_at": 14281614204011638 "updating_firmware": false "updating_firmware_updated_at": 14295002162100337 "app_rootfs_version": "00.86" "app_rootfs_version_updated_at": 14295002174185543 "firmware_version": "0.86.0" "firmware_version_updated_at": 14295002174185324 "update_needed": false "update_needed_updated_at": 14295002174185612 "mac_address": "xxx" "mac_address_updated_at": 142950021741854 "ip_address": "10.0.1.7" "ip_address_updated_at": 14295002174185476 "hub_version": "00.01" "hub_version_updated_at": 1429500217418519 "pairing_mode": null "pairing_mode_updated_at": 14278416920884776 "desired_pairing_mode": null "desired_pairing_mode_updated_at": 1427841692088467 "lat_lng": 26010181 -80146535 "location": "" "configuration": "kidde_radio_code": 0 "update_needed": false "uuid": "xxx" "light_bulb_id": "xxx" "name": "Office" "locale": "en_us" "units": {} "created_at": 1425698691 "hidden_at": null "capabilities": {} "triggers": "desired_state": "powered": true "brightness": 1 "manufacturer_device_model": "ge_" "manufacturer_device_id": null "device_manufacturer": "ge" "model_name": "GE light bulb" "upc_id": "xxx" "hub_id": "xxx" "local_id": "1" "radio_type": "zigbee" "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 14295008188442252 "firmware_version": "0.1b03 / 0.4b00" "firmware_version_updated_at": 14295008188442593 "firmware_date_code": "20140812" "firmware_date_code_updated_at": 14295008188442357 "powered": true "powered_updated_at": 1429500818844245 "brightness": 1 "brightness_updated_at": 1429500818844252 "desired_powered": true "desired_powered_updated_at": 14284902049604716 "desired_brightness": 1 "desired_brightness_updated_at": 14256988979915164 "lat_lng": null null "location": "" "order": 0 "last_reading": "connection": null "connection_updated_at": null "battery": 018 "battery_updated_at": 14294979693582497 "inventory": 1 "inventory_updated_at": 14294979693756864 "age": 1429454667 "age_updated_at": 14294979693756976 "freshness_remaining": 1771098 "freshness_remaining_updated_at": 1429497969375706 "egg_1_timestamp": 0 "egg_1_timestamp_updated_at": 14294979693104246 "egg_2_timestamp": 0 "egg_2_timestamp_updated_at": 1429497969310436 "egg_3_timestamp": 0 "egg_3_timestamp_updated_at": 14294979693104434 "egg_4_timestamp": 0 "egg_4_timestamp_updated_at": 1429497969310451 "egg_5_timestamp": 0 "egg_5_timestamp_updated_at": 14294979693104584 "egg_6_timestamp": 0 "egg_6_timestamp_updated_at": 1429497969310465 "egg_7_timestamp": 0 "egg_7_timestamp_updated_at": 14294979693104732 "egg_8_timestamp": 0 "egg_8_timestamp_updated_at": 14294979693104823 "egg_9_timestamp": 0 "egg_9_timestamp_updated_at": 14294979693104892 "egg_10_timestamp": 0 "egg_10_timestamp_updated_at": 1429497969310498 "egg_11_timestamp": 0 "egg_11_timestamp_updated_at": 14294979693105059 "egg_12_timestamp": 1429454667 "egg_12_timestamp_updated_at": 14294979693105128 "egg_13_timestamp": 0 "egg_13_timestamp_updated_at": 14294979693105197 "egg_14_timestamp": 0 "egg_14_timestamp_updated_at": 14294979693105266 "eggs": 0 0 0 0 0 0 0 0 0 0 0 1429454667 0 0 "freshness_period": 1814400 "eggtray_id": "147424" "name": "Egg Minder" "locale": "en_us" "units": {} "created_at": 1425701549 "hidden_at": null "capabilities": {} "triggers": "device_manufacturer": "quirky_ge" "model_name": "Egg Minder" "upc_id": "23" "lat_lng": 26496337 -80063654 "location": "" "mac_address": "xxx" "serial": "xxx" "light_bulb_id": "xxx" "name": "Stairs" "locale": "en_us" "units": {} "created_at": 1426846362 "hidden_at": null "capabilities": {} "triggers": "desired_state": "powered": false "brightness": 1 "manufacturer_device_model": "lutron_p_pkg1_p_wh_d" "manufacturer_device_id": null "device_manufacturer": "lutron" "model_name": "Caseta Lamp Dimmer & Pico" "upc_id": "xx" "hub_id": "xxx" "local_id": "2" "radio_type": "lutron" "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 14295002453731902 "powered": false "powered_updated_at": 14295002453732066 "brightness": 1 "brightness_updated_at": 14295002453731997 "desired_powered": false "desired_powered_updated_at": 14293283384158955 "desired_brightness": 1 "desired_brightness_updated_at": 14273305290827518 "lat_lng": null null "location": "" "order": 0 "remote_id": "xxx" "name": "Stairs up wallmount" "members": "object_type": "light_bulb" "object_id": "xxx" "desired_state": "powered": false "powered_updated_at": 14293283384158955 "brightness": 1 "brightness_updated_at": 14273305290827518 "locale": "en_us" "units": {} "created_at": 1426847605 "hidden_at": null "capabilities": {} "desired_state": {} "device_manufacturer": "lutron" "model_name": "Pico" "upc_id": "xx" "hub_id": "xxx" "local_id": "3" "radio_type": "lutron" "last_reading": "connection": null "connection_updated_at": null "remote_pairable": true "remote_pairable_updated_at": 14281614204384034 "lat_lng": 26496324 -80063659 "location": "" "remote_id": "xxx" "name": "Stairs detached" "members": "object_type": "light_bulb" "object_id": "xxx" "desired_state": "powered": false "powered_updated_at": 14293283384158955 "brightness": 1 "brightness_updated_at": 14273305290827518 "locale": "en_us" "units": {} "created_at": 1426896325 "hidden_at": null "capabilities": {} "desired_state": {} "device_manufacturer": "lutron" "model_name": "Pico" "upc_id": "xx" "hub_id": "xxx" "local_id": "4" "radio_type": "lutron" "last_reading": "connection": null "connection_updated_at": null "remote_pairable": true "remote_pairable_updated_at": 14281614204671366 "lat_lng": 26481714 -800851 "location": "" "light_bulb_id": "111" "name": "Kitchen" "locale": "en_us" "units": {} "created_at": 1427841678 "hidden_at": null "capabilities": {} "triggers": "desired_state": "powered": false "brightness": 076 "manufacturer_device_model": "lutron_p_pkg1_w_wh_d" "manufacturer_device_id": null "device_manufacturer": "lutron" "model_name": "Caseta Wireless Dimmer & Pico" "upc_id": "3" "hub_id": "xxx" "local_id": "5" "radio_type": "lutron" "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 1429500246530256 "powered": false "powered_updated_at": 14295002465302837 "brightness": 076 "brightness_updated_at": 14295002465302727 "desired_powered": false "desired_powered_updated_at": 14294952296978345 "desired_brightness": 076 "desired_brightness_updated_at": 14295002465847015 "lat_lng": 2649635 -80063667 "location": "" "order": 0 "hub_id": "xxx" "name": "Hub" "locale": "en_us" "units": {} "created_at": 1429049123 "hidden_at": null "capabilities": {} "triggers": "desired_state": "pairing_mode": null "manufacturer_device_model": "philips" "manufacturer_device_id": "xxx" "device_manufacturer": null "model_name": null "upc_id": null "last_reading": "connection": true "connection_updated_at": 14290491233954115 "agent_session_id": null "agent_session_id_updated_at": null "remote_pairable": null "remote_pairable_updated_at": null "updating_firmware": null "updating_firmware_updated_at": null "app_rootfs_version": null "app_rootfs_version_updated_at": null "firmware_version": null "firmware_version_updated_at": null "update_needed": false "update_needed_updated_at": 14290491233314805 "mac_address": null "mac_address_updated_at": null "ip_address": null "ip_address_updated_at": null "hub_version": null "hub_version_updated_at": null "pairing_mode": null "pairing_mode_updated_at": null "desired_pairing_mode": null "desired_pairing_mode_updated_at": null "lat_lng": null null "location": "" "configuration": null "update_needed": false "uuid": "xxx" "light_bulb_id": "xxx" "name": "LightStrips 2" "locale": "en_us" "units": {} "created_at": 1429049124 "hidden_at": 1429203619 "capabilities": {} "triggers": "desired_state": "powered": true "brightness": 1 "manufacturer_device_model": "LST001" "manufacturer_device_id": "xxx" "device_manufacturer": "philips" "model_name": "HUE A19 Lighting Kit" "upc_id": "1" "hub_id": "137069" "local_id": "2" "radio_type": null "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 14290491243448753 "powered": null "powered_updated_at": null "brightness": null "brightness_updated_at": null "desired_powered": true "desired_powered_updated_at": 14290491242762687 "desired_brightness": 1 "desired_brightness_updated_at": 14290491242762783 "lat_lng": null null "location": "" "order": 0 "light_bulb_id": "xxx" "name": "LightStrips 1" "locale": "en_us" "units": {} "created_at": 1429049124 "hidden_at": 1429321559 "capabilities": {} "triggers": "desired_state": "powered": true "brightness": 1 "manufacturer_device_model": "LST001" "manufacturer_device_id": "xxx" "device_manufacturer": "philips" "model_name": "HUE A19 Lighting Kit" "upc_id": "1" "hub_id": "xxx" "local_id": "1" "radio_type": null "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 14290491244880855 "powered": null "powered_updated_at": null "brightness": null "brightness_updated_at": null "desired_powered": true "desired_powered_updated_at": 1429049124393545 "desired_brightness": 1 "desired_brightness_updated_at": 14290491243935578 "lat_lng": null null "location": "" "order": 0 "errors": "pagination": "count": 10
.device(device_name, callback)
Retrieve device by its name
wink;
.device_group(group).device_id(id).get(callback)
Retrieve device by its group and unique id
wink;
.device_group(group).device_id(id).update(data,callback)
Update device
wink;
Models
device_group
String device type id: "light_bulbs"
device_id
Number device identifier
===
Lights (light_bulbs group)
brightness(level, callback)
Set level of brighntess (0-100);
power
on(callback)
turn on lights
off(callback)
turn off lights
toggle(callback)
toggle lights
wink;wink;wink;wink;
raw response from wink:
"light_bulb_id": "xxx" "name": "Stairs" "locale": "en_us" "units": {} "created_at": 1426846362 "hidden_at": null "capabilities": {} "triggers": "desired_state": "powered": false "brightness": 1 "manufacturer_device_model": "lutron_p_pkg1_p_wh_d" "manufacturer_device_id": null "device_manufacturer": "lutron" "model_name": "Caseta Lamp Dimmer & Pico" "upc_id": "33" "hub_id": "114516" "local_id": "2" "radio_type": "lutron" "linked_service_id": null "last_reading": "connection": true "connection_updated_at": 14295002453731902 "powered": false "powered_updated_at": 14295002453732066 "brightness": 1 "brightness_updated_at": 14295002453731997 "desired_powered": false "desired_powered_updated_at": 14293283384158955 "desired_brightness": 1 "desired_brightness_updated_at": 14273305290827518 "lat_lng": null null "location": "" "order": 0
Eggtray
quantity
Number Returns quantity of eggs
raw response:
"last_reading": "connection": null "connection_updated_at": null "battery": 018 "battery_updated_at": 14295412745857081 "inventory": 1 "inventory_updated_at": 1429541274631489 "age": 1429454667 "age_updated_at": 14295412746315 "freshness_remaining": 1727793 "freshness_remaining_updated_at": 14295412746315074 "egg_1_timestamp": 0 "egg_1_timestamp_updated_at": 14295412745594687 "egg_2_timestamp": 0 "egg_2_timestamp_updated_at": 1429541274559478 "egg_3_timestamp": 0 "egg_3_timestamp_updated_at": 14295412745594845 "egg_4_timestamp": 0 "egg_4_timestamp_updated_at": 14295412745594902 "egg_5_timestamp": 0 "egg_5_timestamp_updated_at": 14295412745594962 "egg_6_timestamp": 0 "egg_6_timestamp_updated_at": 14295412745595021 "egg_7_timestamp": 0 "egg_7_timestamp_updated_at": 1429541274559508 "egg_8_timestamp": 0 "egg_8_timestamp_updated_at": 14295412745595133 "egg_9_timestamp": 0 "egg_9_timestamp_updated_at": 1429541274559519 "egg_10_timestamp": 0 "egg_10_timestamp_updated_at": 14295412745595248 "egg_11_timestamp": 0 "egg_11_timestamp_updated_at": 14295412745595305 "egg_12_timestamp": 1429454667 "egg_12_timestamp_updated_at": 14295412745595367 "egg_13_timestamp": 0 "egg_13_timestamp_updated_at": 1429541274559543 "egg_14_timestamp": 0 "egg_14_timestamp_updated_at": 14295412745595486 "eggs": 0 0 0 0 0 0 0 0 0 0 0 1429454667 0 0 "freshness_period": 1814400 "eggtray_id": "xxx" "name": "Egg Minder" "locale": "en_us" "units": {} "created_at": 1425701549 "hidden_at": null "capabilities": {} "triggers": "device_manufacturer": "quirky_ge" "model_name": "Egg Minder" "upc_id": "23" "lat_lng": 26496337 -80063654 "location": "" "mac_address": "xxx" "serial": "xxx"
Thermostat
temperature(max, min, unit, callback)
Change temperature, where:
- max is maximum temperature is going to reach
- min is minimum temperature can fall
- unit should be 'c' or 'f' (Celsius or Fahrenheit)
- callback(return) results status
wink;
temperature(max, unit?, callback?)
Change temperature, where:
- max is maximum temperature is going to reach
- unit should be 'c' or 'f' (Celsius or Fahrenheit)
- callback(return) results status
min temperature is going to default to max - 2 degrees in specified units
wink;
temperature(max, callback)
Change temperature, where:
- max is maximum temperature is going to reach
- callback(return) results status
unit is going to default to setting in the thermostat
wink;
temperature(max, unit, callback)
Change temperature, where:
- max is maximum temperature is going to reach
- unit should be 'c' or 'f' (Celsius or Fahrenheit)
- callback(return) results status
wink;
temperature(max, min, callback)
Change temperature, where:
- max is maximum temperature is going to reach
- min is minimum temperature can fall
- callback(return) results status
unit is going to default to setting in the thermostat
wink;
temperature(callback)
Get temperature:
- callback(temp)
unit is going to default to setting in the thermostat
wink;
temperature()
Returns temperature:
unit is going to default to setting in the thermostat
wink;
temperature(unit)
Returns temperature in specified unit
- unit can be 'c' or 'f'
wink;
temperature(unit, callback)
Returns temperature in specified unit
- unit can be 'c' or 'f'
- callback(temp)
- temp is rounded, when unit is set to 'f'
wink;
complete object dump:
"thermostat_id": "54114" "name": "Home Downstairs Thermostat" "locale": "en_us" "units": "temperature": "f" "created_at": 1430018697 "hidden_at": null "capabilities": {} "triggers": "desired_state": "mode": "cool_only" "powered": true "min_set_point": 20 "max_set_point": 22 "users_away": false "fan_timer_active": false "manufacturer_device_model": "nest" "manufacturer_device_id": "zcx9ETvEqC3IdY6KyWEhbUxx11Qobba_" "device_manufacturer": "nest" "model_name": "Learning Thermostat" "upc_id": "168" "hub_id": null "local_id": null "radio_type": null "linked_service_id": "102939" "last_reading": "connection": true "connection_updated_at": 14300800366664212 "mode": "cool_only" "mode_updated_at": 14300800366664522 "powered": true "powered_updated_at": 1430080036666473 "min_set_point": 20 "min_set_point_updated_at": 14300187677561078 "max_set_point": 22 "max_set_point_updated_at": 14300800366664915 "users_away": false "users_away_updated_at": 14300800366665094 "fan_timer_active": false "fan_timer_active_updated_at": 1430080036666485 "temperature": 23 "temperature_updated_at": 1430080036666439 "external_temperature": null "external_temperature_updated_at": null "deadband": 15 "deadband_updated_at": 14300800366664457 "min_min_set_point": null "min_min_set_point_updated_at": null "max_min_set_point": null "max_min_set_point_updated_at": null "min_max_set_point": null "min_max_set_point_updated_at": null "max_max_set_point": null "max_max_set_point_updated_at": null "modes_allowed": "auto" "heat_only" "cool_only" "modes_allowed_updated_at": 14300800366664972 "units": "f" "units_updated_at": 14300800366664321 "eco_target": false "eco_target_updated_at": 14300800366664586 "manufacturer_structure_id": "mNN4pWJ2yWpMfFSjA_drSBU1RSNN0MXjiHypikpG4mwMnXS-pHxfPw" "manufacturer_structure_id_updated_at": 14300800366664662 "has_fan": true "has_fan_updated_at": 14300800366664789 "fan_duration": 0 "fan_duration_updated_at": 14300800366665034 "last_error": "too_many_requests" "last_error_updated_at": 14300196842469466 "desired_mode": "cool_only" "desired_mode_updated_at": 14300186975703063 "desired_powered": true "desired_powered_updated_at": 14300188017444894 "desired_min_set_point": 20 "desired_min_set_point_updated_at": 1430018765197387 "desired_max_set_point": 22 "desired_max_set_point_updated_at": 1430067786578795 "desired_users_away": false "desired_users_away_updated_at": 14300186975703213 "desired_fan_timer_active": false "desired_fan_timer_active_updated_at": 14300186975703301 "lat_lng": 26266677 -80127683 "location": "" "smart_schedule_enabled": false