├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app.js ├── app.json ├── assets └── icon.svg ├── custom_components └── homey │ ├── __init__.py │ ├── example.yaml │ └── manifest.json ├── drivers ├── binary_sensor │ ├── assets │ │ ├── icon.svg │ │ ├── icons │ │ │ ├── alarm_contact.svg │ │ │ ├── alarm_generic.svg │ │ │ ├── alarm_heat.svg │ │ │ ├── alarm_motion.svg │ │ │ ├── alarm_pressure.svg │ │ │ ├── alarm_smoke.svg │ │ │ ├── alarm_tamper.svg │ │ │ └── alarm_water.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── compound │ ├── assets │ │ ├── icon.svg │ │ ├── icons │ │ │ ├── alarm_contact.svg │ │ │ ├── alarm_generic.svg │ │ │ ├── alarm_heat.svg │ │ │ ├── alarm_motion.svg │ │ │ ├── alarm_pressure.svg │ │ │ ├── alarm_smoke.svg │ │ │ ├── alarm_tamper.svg │ │ │ ├── alarm_water.svg │ │ │ ├── co2.svg │ │ │ ├── measure_battery.svg │ │ │ ├── measure_humidity.svg │ │ │ ├── measure_luminance.svg │ │ │ ├── measure_power.svg │ │ │ ├── measure_pressure.svg │ │ │ ├── measure_temperature.svg │ │ │ ├── meter_power.svg │ │ │ └── noise.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── light │ ├── assets │ │ ├── icon.svg │ │ ├── icons │ │ │ ├── LCT001.svg │ │ │ ├── LCT002.svg │ │ │ ├── LCT003.svg │ │ │ ├── LCT012.svg │ │ │ ├── LLC001.svg │ │ │ ├── LLC007.svg │ │ │ ├── LLC010.svg │ │ │ ├── LLC011.svg │ │ │ ├── LLC013.svg │ │ │ ├── LLC020.svg │ │ │ ├── LST001.svg │ │ │ └── LWB006.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── scene │ ├── assets │ │ ├── icon.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── script │ ├── assets │ │ ├── icon.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── sensor │ ├── assets │ │ ├── icon.svg │ │ ├── icons │ │ │ ├── co2.svg │ │ │ ├── measure_battery.svg │ │ │ ├── measure_humidity.svg │ │ │ ├── measure_luminance.svg │ │ │ ├── measure_power.svg │ │ │ ├── measure_pressure.svg │ │ │ ├── measure_temperature.svg │ │ │ ├── meter_power.svg │ │ │ └── noise.svg │ │ └── images │ │ │ ├── large.jpg │ │ │ └── small.jpg │ ├── device.js │ └── driver.js └── switch │ ├── assets │ ├── icon.svg │ ├── icons │ │ ├── off.svg │ │ └── on.svg │ └── images │ │ ├── large.jpg │ │ └── small.jpg │ ├── device.js │ └── driver.js ├── lib └── Client.js ├── locales ├── en.json └── nl.json ├── node_modules ├── async-limiter │ ├── .travis.yml │ ├── LICENSE │ ├── coverage │ │ ├── coverage.json │ │ ├── lcov-report │ │ │ ├── async-throttle │ │ │ │ ├── index.html │ │ │ │ └── index.js.html │ │ │ ├── base.css │ │ │ ├── index.html │ │ │ ├── prettify.css │ │ │ ├── prettify.js │ │ │ ├── sort-arrow-sprite.png │ │ │ └── sorter.js │ │ └── lcov.info │ ├── index.js │ ├── package.json │ └── readme.md ├── home-assistant-js-websocket │ ├── LICENSE.md │ ├── README.md │ ├── dist │ │ ├── auth.d.ts │ │ ├── collection.d.ts │ │ ├── commands.d.ts │ │ ├── config.d.ts │ │ ├── connection.d.ts │ │ ├── entities.d.ts │ │ ├── errors.d.ts │ │ ├── haws.es.js │ │ ├── haws.es.js.map │ │ ├── haws.js │ │ ├── haws.js.map │ │ ├── haws.umd.js │ │ ├── haws.umd.js.map │ │ ├── index.d.ts │ │ ├── messages.d.ts │ │ ├── services.d.ts │ │ ├── socket.d.ts │ │ ├── store.d.ts │ │ ├── types.d.ts │ │ └── util.d.ts │ └── package.json └── ws │ ├── LICENSE │ ├── README.md │ ├── browser.js │ ├── index.js │ ├── lib │ ├── buffer-util.js │ ├── constants.js │ ├── event-target.js │ ├── extension.js │ ├── permessage-deflate.js │ ├── receiver.js │ ├── sender.js │ ├── validation.js │ ├── websocket-server.js │ └── websocket.js │ └── package.json ├── package-lock.json └── settings └── index.html /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | education, socio-economic status, nationality, personal appearance, race, 10 | religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at support@athom.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Athom and Homey 2 | 3 | First off all, thank you for taking the time to contribute! 4 | 5 | The following is a set of guidelines for contributing to Athom and its packages, which are hosted in the [Athom Organization](https://github.com/athombv) on GitHub. These are just guidelines, not rules. Use your best judgment, and feel free to contact us if you have any questions. 6 | 7 | Please join our [community slack](https://slack.athom.com), if you have not done so already. 8 | We also have a [community forum](https://community.athom.com) for general discussions. 9 | 10 | 11 | ## Before submitting a bug or feature request 12 | 13 | * **Have you actually read the error message**? 14 | * Have you searched for similar issues? 15 | * Have you updated homey, all apps, and the development tools (if applicable)? 16 | * Have you checked that it's not a problem with one of the apps you're using, rather than Homey itself? 17 | * Have you looked at what's involved in fixing/implementing this? 18 | 19 | Capable programmers should always attempt to investigate and fix problems themselves before asking for others to help. Submit a pull request instead of an issue! 20 | 21 | Regular support is provided through our [support staff](support@athom.com). 22 | 23 | ## A great bug report contains 24 | 25 | * Context – what were you trying to achieve? 26 | * Detailed steps to reproduce the error from scratch. Try isolating the minimal amount of code needed to reproduce the error. 27 | * Any applicable log files or ID's. 28 | * Evidence you've looked into solving the problem and ideally, a theory on the cause and a possible solution. 29 | 30 | ## A great feature request contains 31 | 32 | * The current situation. 33 | * How and why the current situation is problematic. 34 | * A detailed proposal or pull request that demonstrates how the problem could be solved. 35 | * A use case – who needs this feature and why? 36 | * Any caveats. 37 | 38 | ## A great pull request contains 39 | 40 | * Minimal changes. Only submit code relevant to the current issue. Other changes should go in new pull requests. 41 | * Minimal commits. Please squash to a single commit before sending your pull request. 42 | * No conflicts. Please rebase off the latest master before submitting. 43 | * Code conforming to the existing conventions and formats. i.e. Please don't reformat whitespace. 44 | * Passing tests in the test folder (if applicable). Use existing tests as a reference. 45 | * Relevant documentation. 46 | 47 | ## Speeding up your pull request 48 | Merging pull requests takes time. While we always try to merge your pull request as soon as possible, there are certain things you can do to speed up this process. 49 | 50 | * Ask developers to review your code changes and post their feedback. 51 | * Ask users to test your changes and post their feedback. 52 | * Keep your changes to the minimal required amount, and dedicated to one issue/feature only. 53 | * If your PR introduces new features or more than just a small fix, please sign our [Contributor License Agreement](https://go.athom.com/cla). 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Home-Assistant integation for Homey by Athom 2 | 3 | This application allows you to add your home-assistant (http://home-assistant.io) devices to your Homey. 4 | 5 | ## Requirements 6 | - Home-assistant 0.78+ 7 | - Homey :) 8 | 9 | ## The list of currently support types: 10 | - sensors 11 | - binary_sensors 12 | - switches 13 | - light 14 | - scenes 15 | - scripts 16 | 17 | ## Getting started 18 | To connect the application to your home-assistant instance you will need to create a `Long Lived Access Token` in home-assistant. You can create a token on your home-assistant account profile page (https://www.home-assistant.io/docs/authentication/). 19 | 20 | You will also need to know the ip-address/hostname of your home-assistant instance. 21 | 22 | Install the application on your Homey and then go into the application settings. 23 | 24 | Fill in the correct address (e.g. http://127.0.0.1:8123) and the access token you have created inside home-assistant and then press "Save changes". 25 | 26 | In case you have entered the correct settings it should show "Successfully connected". 27 | 28 | Now you can add the devices you want to use within Homey 29 | 30 | ## Flow action 31 | Besides the ability to add devices and use them in your Homey flows there is also a flow action available to directly call home-assistant services inside flows. 32 | 33 | ## Compounds 34 | Because Homey and home-assistant are modeled differently when it comes to devices it makes sense to group multiple sensors from home-assistant into one Homey device. 35 | 36 | To do so you will have to install a custom component in your home-assistant installation: 37 | https://github.com/rogro82/io.homeassistant/blob/master/custom_component/homey.py 38 | 39 | After adding the custom component you can now declare the homey platform in your home-assistant configuration and define your devices. 40 | 41 | Example: 42 | ```yaml 43 | homey: 44 | livingroom_sensor: 45 | name: Livingroom environment 46 | icon: alarm_motion 47 | capabilities: 48 | measure_temperature: sensor.livingroom_temperature 49 | measure_humidity: sensor.livingroom_humidity 50 | measure_luminance: sensor.livingroom_luminance 51 | alarm_motion: binary_sensor.livingroom_motion 52 | alarm_contact: binary_sensor.toilet_door 53 | button: script.test 54 | onoff: switch.ventilation 55 | dim: input_number.test_slider 56 | capabilitiesConverters: 57 | measure_temperature: 58 | from: (state) => { return parseFloat(state) * 2; } 59 | to: (value) => { return value / 2; } 60 | dim: 61 | from: (state) => { return parseFloat(state) * 0.01; } 62 | to: (value) => { return value * 100; } 63 | ``` 64 | 65 | After reloading your home-assistant configuration you can add it in Homey by selecting `Compound` in the `Choose a device` dialog. -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | const Client = require('./lib/Client.js'); 5 | 6 | class App extends Homey.App { 7 | 8 | onInit() { 9 | super.onInit(); 10 | 11 | this.log('Home-Assistant is running...'); 12 | 13 | let address = Homey.ManagerSettings.get("address"); 14 | let token = Homey.ManagerSettings.get("token"); 15 | 16 | this._client = new Client(address, token) 17 | .on("connection_update", (state) => { 18 | Homey.ManagerApi.realtime('connection_update', state); 19 | }); 20 | 21 | this._onFlowActionCallService = this._onFlowActionCallService.bind(this); 22 | 23 | new Homey.FlowCardAction('callService') 24 | .register() 25 | .registerRunListener( this._onFlowActionCallService ); 26 | 27 | Homey.ManagerSettings.on("set", this._reconnectClient.bind(this)); 28 | } 29 | 30 | getClient() { 31 | return this._client; 32 | } 33 | 34 | _reconnectClient(arg) { 35 | console.log("settings updated.... reconnecting"); 36 | 37 | let address = Homey.ManagerSettings.get("address"); 38 | let token = Homey.ManagerSettings.get("token"); 39 | 40 | this._client.connect(address, token, true); 41 | } 42 | 43 | _onFlowActionCallService(args) { 44 | this._client.callService(args.domain, args.service, args.data); 45 | } 46 | } 47 | 48 | module.exports = App; -------------------------------------------------------------------------------- /custom_components/homey/__init__.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | import json 4 | 5 | import voluptuous as vol 6 | 7 | from homeassistant.const import (CONF_NAME, ATTR_ICON) 8 | from homeassistant.helpers import config_validation as cv 9 | from homeassistant.loader import bind_hass 10 | from homeassistant.helpers.entity import Entity 11 | from homeassistant.helpers.entity_component import EntityComponent 12 | 13 | _LOGGER = logging.getLogger(__name__) 14 | 15 | DOMAIN = 'homey' 16 | ENTITY_ID_FORMAT = DOMAIN + '.{}' 17 | 18 | CONF_ICON = "icon" 19 | CONF_CAPABILITIES = "capabilities" 20 | CONF_CAPABILITIES_CONVERTERS = "capabilitiesConverters" 21 | 22 | CONFIG_SCHEMA = vol.Schema({ 23 | DOMAIN: vol.Schema({ 24 | cv.slug: vol.Any({ 25 | vol.Optional(CONF_NAME): cv.string, 26 | vol.Optional(CONF_ICON): cv.string, 27 | vol.Optional(CONF_CAPABILITIES): dict, 28 | vol.Optional(CONF_CAPABILITIES_CONVERTERS): dict 29 | }, None) 30 | }) 31 | }, extra=vol.ALLOW_EXTRA) 32 | 33 | @asyncio.coroutine 34 | def async_setup(hass, config): 35 | """Set up variables.""" 36 | component = EntityComponent(_LOGGER, DOMAIN, hass) 37 | 38 | devices = [] 39 | 40 | for device_id, device_config in config[DOMAIN].items(): 41 | if not device_config: 42 | device_config = {} 43 | 44 | name = device_config.get(CONF_NAME) 45 | icon = device_config.get(CONF_ICON) 46 | capabilities = device_config.get(CONF_CAPABILITIES) 47 | capabilitiesConverters = device_config.get(CONF_CAPABILITIES_CONVERTERS) 48 | 49 | devices.append(Device(device_id, name, icon, capabilities, capabilitiesConverters)) 50 | 51 | yield from component.async_add_entities(devices) 52 | return True 53 | 54 | class Device(Entity): 55 | """Representation of a homey device.""" 56 | 57 | def __init__(self, device_id, name, icon, capabilities, capabilitiesConverters): 58 | """Initialize a homey device.""" 59 | self.entity_id = ENTITY_ID_FORMAT.format(device_id) 60 | self._name = name 61 | self._icon = icon 62 | self._capabilities = capabilities 63 | self._capabilitiesConverters = capabilitiesConverters 64 | 65 | @asyncio.coroutine 66 | def async_added_to_hass(self): 67 | """Run when entity about to be added.""" 68 | super().async_added_to_hass() 69 | 70 | @property 71 | def should_poll(self): 72 | """If entity should be polled.""" 73 | return False 74 | 75 | @property 76 | def name(self): 77 | """Return the name of the variable.""" 78 | return self._name 79 | 80 | @property 81 | def icon(self): 82 | """Return the icon to be used for this entity.""" 83 | return None 84 | 85 | @property 86 | def state(self): 87 | """Return the state of the component.""" 88 | return "" 89 | 90 | @property 91 | def state_attributes(self): 92 | """Return the state attributes.""" 93 | return { 94 | "icon": self._icon, 95 | "capabilities": self._capabilities, 96 | "capabilitiesConverters": self._capabilitiesConverters 97 | } 98 | -------------------------------------------------------------------------------- /custom_components/homey/example.yaml: -------------------------------------------------------------------------------- 1 | homey: 2 | livingroom_sensor: 3 | name: Livingroom environment 4 | capabilities: 5 | measure_temperature: sensor.livingroom_temperature 6 | measure_humidity: sensor.livingroom_humidity 7 | measure_luminance: sensor.livingroom_luminance 8 | alarm_motion: binary_sensor.livingroom_motion 9 | alarm_contact: binary_sensor.toilet_door 10 | button: script.test 11 | onoff: switch.ventilation 12 | dim: input_number.test_slider 13 | capabilitiesConverters: 14 | measure_temperature: 15 | from: (state) => { return parseFloat(state) * 2; } 16 | to: (value) => { return value / 2; } 17 | dim: 18 | from: (state) => { return parseFloat(state) * 0.01; } 19 | to: (value) => { return value * 100; } -------------------------------------------------------------------------------- /custom_components/homey/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": "homey", 3 | "name": "homey", 4 | "documentation": "https://github.com/rogro82/io.homeassistant", 5 | "requirements": [], 6 | "dependencies": [], 7 | "codeowners": [ 8 | "@rogro82" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_contact.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_generic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_heat.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_motion.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_smoke.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_tamper.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/icons/alarm_water.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/binary_sensor/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/binary_sensor/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/binary_sensor/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/binary_sensor/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class BinarySensorDevice extends Homey.Device { 6 | 7 | onInit() { 8 | this._client = Homey.app.getClient(); 9 | 10 | this.entityId = this.getData().id; 11 | this.capabilities = this.getCapabilities(); 12 | 13 | this.log('device init'); 14 | this.log('id:', this.entityId); 15 | this.log('name:', this.getName()); 16 | this.log('class:', this.getClass()); 17 | 18 | this._client.registerDevice(this.entityId, this); 19 | 20 | let entity = this._client.getEntity(this.entityId); 21 | if(entity) { 22 | this.onEntityUpdate(entity); 23 | } 24 | 25 | this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)) 26 | } 27 | 28 | onAdded() { 29 | this.log('device added'); 30 | } 31 | 32 | onDeleted() { 33 | this.log('device deleted'); 34 | this._client.unregisterDevice(this.entityId); 35 | } 36 | 37 | onEntityUpdate(data) { 38 | try { 39 | 40 | this.capabilities.forEach(capability => { 41 | this.setCapabilityValue(capability, data.state == "on"); 42 | }); 43 | 44 | } catch(ex) { 45 | console.log("error", ex); 46 | } 47 | } 48 | 49 | onCapabilityOnoff( value, opts, callback ) { 50 | let oldValue = this.getCapabilityValue('onoff'); 51 | 52 | callback(null, true); 53 | this.setCapabilityValue("onoff", oldValue); 54 | } 55 | } 56 | 57 | module.exports = BinarySensorDevice; -------------------------------------------------------------------------------- /drivers/binary_sensor/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class BinarySensorDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let sensors = client.getBinarySensors(); 11 | 12 | callback(null, sensors); 13 | } 14 | 15 | } 16 | 17 | module.exports = BinarySensorDriver; -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_contact.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_generic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_heat.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_motion.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_smoke.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_tamper.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/alarm_water.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/co2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 12 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_battery.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | device_battery_charge_outline_stroke 10 | Created with Sketch. 11 | 12 | 13 | 14 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_humidity.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 23 | 24 | 26 | 27 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_luminance.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 31 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_power.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xmlPP 78 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_pressure.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/measure_temperature.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/meter_power.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 21 | 22 | -------------------------------------------------------------------------------- /drivers/compound/assets/icons/noise.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 12 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /drivers/compound/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/compound/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/compound/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/compound/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/compound/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | const defaultValueConverter = { 6 | from: (state) => parseFloat(state), 7 | to: (value) => value 8 | } 9 | 10 | const defaultBooleanConverter = { 11 | from: (state) => (state == "on"), 12 | to: (value) => (value ? "on" : "off") 13 | } 14 | 15 | class CompoundDevice extends Homey.Device { 16 | 17 | onInit() { 18 | this._client = Homey.app.getClient(); 19 | 20 | this.entityId = this.getData().id; 21 | this.capabilities = this.getCapabilities(); 22 | this.compoundCapabilities = this.getData().capabilities; 23 | this.compoundCapabilitiesConverters = this.getData().capabilitiesConverters; 24 | 25 | this.log('device init'); 26 | this.log('id:', this.entityId); 27 | this.log('name:', this.getName()); 28 | this.log('class:', this.getClass()); 29 | 30 | this._client.registerDevice(this.entityId, this); 31 | 32 | if(this.hasCapability("button")) { 33 | this.registerCapabilityListener('button', this.onCapabilityButton.bind(this)) 34 | } 35 | 36 | if(this.hasCapability("onoff")) { 37 | this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)) 38 | } 39 | 40 | if(this.hasCapability("locked")) { 41 | this.registerCapabilityListener('locked', this.onCapabilityLocked.bind(this)) 42 | } 43 | 44 | if(this.hasCapability("dim")) { 45 | console.log("attach dim listener"); 46 | this.registerCapabilityListener('dim', this.onCapabilityDim.bind(this)) 47 | } 48 | } 49 | 50 | inputConverter(capability) { 51 | let capabilityConverter = this.compoundCapabilitiesConverters[capability]; 52 | 53 | if(capabilityConverter != null) { 54 | if(capabilityConverter.from && typeof capabilityConverter.from === "function") { 55 | return capabilityConverter.from; 56 | } else if(capabilityConverter.from && typeof capabilityConverter.from === "string") { 57 | capabilityConverter.from = eval(capabilityConverter.from); 58 | return capabilityConverter.from; 59 | } 60 | } 61 | 62 | if(capability.startsWith("measure_") || 63 | capability == "dim") { 64 | return defaultValueConverter.from; 65 | } else { 66 | return defaultBooleanConverter.from; 67 | } 68 | } 69 | 70 | outputConverter(capability) { 71 | let capabilityConverter = this.compoundCapabilitiesConverters[capability]; 72 | if(capabilityConverter != null) { 73 | if(capabilityConverter.to && typeof capabilityConverter.to === "function") { 74 | return capabilityConverter.to; 75 | } else if(capabilityConverter.to && typeof capabilityConverter.to === "string") { 76 | capabilityConverter.to = eval(capabilityConverter.to); 77 | return capabilityConverter.to; 78 | } 79 | } 80 | 81 | if(capability.startsWith("measure_" || 82 | capability == "dim")) { 83 | return defaultValueConverter.to; 84 | } else { 85 | return defaultBooleanConverter.to; 86 | } 87 | } 88 | 89 | onAdded() { 90 | this.log('device added'); 91 | } 92 | 93 | onDeleted() { 94 | this.log('device deleted'); 95 | this._client.unregisterDevice(this.entityId); 96 | } 97 | 98 | onEntityUpdate(data) { 99 | let entityId = data.entity_id; 100 | 101 | Object.keys(this.compoundCapabilities).forEach(key => { 102 | if(this.compoundCapabilities[key] == entityId) { 103 | 104 | // console.log("---------------------------------------------------------------"); 105 | // console.log("update compound device:", this.entityId); 106 | // console.log("update compound capability:", key); 107 | // console.log("update compound by entity:", entityId); 108 | 109 | let convert = this.inputConverter(key); 110 | 111 | this.setCapabilityValue(key, convert(data.state)); 112 | } 113 | }); 114 | } 115 | 116 | onCapabilityButton( value, opts, callback ) { 117 | this._client.turnOnOff(this.compoundCapabilities["button"], true); 118 | callback( null ); 119 | } 120 | 121 | 122 | onCapabilityOnoff( value, opts, callback ) { 123 | this._client.turnOnOff(this.compoundCapabilities["onoff"], value); 124 | callback( null ); 125 | } 126 | 127 | onCapabilityLocked( value, opts, callback ) { 128 | console.log("onCapabilityLocked", value); 129 | this._client.turnOnOff(this.compoundCapabilities["locked"], value); 130 | callback( null ); 131 | } 132 | 133 | onCapabilityDim( value, opts, callback ) { 134 | let entityId = this.compoundCapabilities["dim"]; 135 | let outputValue = this.outputConverter("dim")(value); 136 | 137 | // TODO: make service calls configurable to allow other types then just input_number 138 | 139 | this._client.callService("input_number", "set_value", { 140 | "entity_id": entityId, 141 | "value": outputValue 142 | }); 143 | callback( null ); 144 | } 145 | } 146 | 147 | module.exports = CompoundDevice; -------------------------------------------------------------------------------- /drivers/compound/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class CompoundDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let sensors = client.getCompounds(); 11 | 12 | callback(null, sensors); 13 | } 14 | 15 | } 16 | 17 | module.exports = CompoundDriver; -------------------------------------------------------------------------------- /drivers/light/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /drivers/light/assets/icons/LCT001.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /drivers/light/assets/icons/LLC011.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 19 | 33 | 35 | 56 | 68 | 69 | -------------------------------------------------------------------------------- /drivers/light/assets/icons/LLC013.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 15 | 16 | 18 | 19 | 21 | 23 | 25 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /drivers/light/assets/icons/LLC020.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 9 | 38 | 39 | -------------------------------------------------------------------------------- /drivers/light/assets/icons/LST001.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /drivers/light/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/light/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/light/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/light/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/light/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | const CAPABILITIES_SET_DEBOUNCE = 100; 6 | 7 | class LightDevice extends Homey.Device { 8 | 9 | onInit() { 10 | this._client = Homey.app.getClient(); 11 | 12 | this.entityId = this.getData().id; 13 | 14 | this._minMireds = 0; 15 | this._maxMireds = 0; 16 | 17 | this.log('device init'); 18 | this.log('id:', this.entityId); 19 | this.log('name:', this.getName()); 20 | this.log('class:', this.getClass()); 21 | 22 | this._client.registerDevice(this.entityId, this); 23 | 24 | let entity = this._client.getEntity(this.entityId); 25 | if(entity) { 26 | this.onEntityUpdate(entity); 27 | } 28 | 29 | this.registerMultipleCapabilityListener(this.getCapabilities(), this._onCapabilitiesSet.bind(this), CAPABILITIES_SET_DEBOUNCE); 30 | } 31 | 32 | onAdded() { 33 | this.log('device added'); 34 | } 35 | 36 | onDeleted() { 37 | this.log('device deleted'); 38 | this._client.unregisterDevice(this.entityId); 39 | } 40 | 41 | onCapabilityOnoff( value, opts, callback ) { 42 | this._client.turnOnOff(this.entityId, value); 43 | callback( null ); 44 | } 45 | 46 | getCapabilityUpdate(valueObj, capability) { 47 | let value = valueObj[capability]; 48 | if(typeof value === 'undefined') value = this.getCapabilityValue(capability) 49 | 50 | return value; 51 | } 52 | 53 | hasCapabilityUpdate(valueObj, capability) { 54 | let value = valueObj[capability]; 55 | return(typeof value !== 'undefined'); 56 | } 57 | 58 | _onCapabilitiesSet(valueObj, optsObj, callback) { 59 | if( typeof valueObj.dim === 'number' ) { 60 | valueObj.onoff = valueObj.dim > 0; 61 | } 62 | 63 | let lightOn = this.getCapabilityUpdate(valueObj, "onoff"); 64 | 65 | let data = { 66 | entity_id: this.entityId 67 | }; 68 | 69 | if(lightOn) { 70 | 71 | if(this.hasCapability("dim")) { 72 | let bri = this.getCapabilityUpdate(valueObj, "dim"); 73 | if(bri != this.getCapabilityValue("dim")) { 74 | data["brightness"] = bri * 250.0; 75 | 76 | this.setCapabilityValue("dim", bri); 77 | } 78 | } 79 | 80 | let lightModeUpdate = null; 81 | 82 | if(this.hasCapabilityUpdate(valueObj, "light_hue") || 83 | this.hasCapabilityUpdate(valueObj, "light_saturation")) { 84 | 85 | lightModeUpdate = "color"; 86 | 87 | let hue = this.getCapabilityUpdate(valueObj, "light_hue"); 88 | let sat = this.getCapabilityUpdate(valueObj, "light_saturation"); 89 | 90 | if(hue != this.getCapabilityValue("light_hue") || 91 | sat != this.getCapabilityValue("light_saturation")) { 92 | 93 | data["hs_color"] = [ 94 | hue * 360.0, 95 | sat * 100.0 96 | ] 97 | 98 | this.setCapabilityValue("light_hue", hue); 99 | this.setCapabilityValue("light_saturation", sat); 100 | } 101 | 102 | } else if(this.hasCapabilityUpdate(valueObj, "light_temperature")) { 103 | lightModeUpdate = "temperature"; 104 | 105 | let tmp = this.getCapabilityUpdate(valueObj, "light_temperature"); 106 | 107 | if(tmp != this.getCapabilityValue("light_temperature")) { 108 | data["color_temp"] = ((this._maxMireds - this._minMireds) * tmp) + this._minMireds; 109 | 110 | this.setCapabilityValue("light_temperature", tmp); 111 | } 112 | } 113 | 114 | if(lightModeUpdate && this.hasCapability("light_mode")) { 115 | this.setCapabilityValue("light_mode", lightModeUpdate); 116 | } 117 | } 118 | 119 | this._client.updateLight(lightOn, data); 120 | 121 | callback(null); 122 | } 123 | 124 | onEntityUpdate(data) { 125 | if(data) { 126 | 127 | this._minMireds = data.attributes["min_mireds"] || 0; 128 | this._maxMireds = data.attributes["max_mireds"] || 0; 129 | 130 | let lightOn = data.state == "on"; 131 | 132 | this.setCapabilityValue("onoff", lightOn); 133 | 134 | if(lightOn) { 135 | 136 | if(this.hasCapability("dim")) { 137 | let brightness = data.attributes["brightness"]; // 0..255 -> 0..1 138 | if(brightness != 0) { 139 | this.setCapabilityValue("dim", 1.0 / 250 * brightness); 140 | } 141 | } 142 | 143 | let hasLightMode = this.hasCapability("light_mode"); 144 | let hs = null; 145 | 146 | if(this.hasCapability("light_hue")) { 147 | hs = data.attributes["hs_color"]; 148 | if(hs) { 149 | let hue = 1.0 / 360.0 * hs[0]; // 0..360 -> 0..1 150 | let sat = 1.0 / 100.0 * hs[1]; // 0..100 -> 0..1 151 | 152 | this.setCapabilityValue("light_hue", hue); 153 | this.setCapabilityValue("light_saturation", sat); 154 | } 155 | } 156 | 157 | if(this.hasCapability("light_temperature")) { 158 | let temperature = data.attributes["color_temp"]; 159 | if(temperature) { 160 | let temp = 1.0 / (this._maxMireds - this._minMireds) * (temperature - this._minMireds); 161 | this.setCapabilityValue("light_temperature", temp); 162 | } 163 | } 164 | 165 | if(hasLightMode) { 166 | let light_mode = hs ? "color" : "temperature"; 167 | 168 | this.setCapabilityValue("light_mode", hs ? "color" : "temperature"); 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | module.exports = LightDevice; -------------------------------------------------------------------------------- /drivers/light/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class LightDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let lights = client.getLights(); 11 | 12 | callback(null, lights); 13 | } 14 | 15 | } 16 | 17 | module.exports = LightDriver; -------------------------------------------------------------------------------- /drivers/scene/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /drivers/scene/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/scene/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/scene/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/scene/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/scene/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SceneDevice extends Homey.Device { 6 | 7 | onInit() { 8 | this._client = Homey.app.getClient(); 9 | 10 | this.entityId = this.getData().id; 11 | 12 | this.log('device init'); 13 | this.log('id:', this.entityId); 14 | this.log('name:', this.getName()); 15 | this.log('class:', this.getClass()); 16 | 17 | this._client.registerDevice(this.entityId, this); 18 | 19 | let entity = this._client.getEntity(this.entityId); 20 | if(entity) { 21 | this.onEntityUpdate(entity); 22 | } 23 | 24 | this.registerCapabilityListener('button', this.onCapabilityButton.bind(this)) 25 | } 26 | 27 | onAdded() { 28 | this.log('device added'); 29 | } 30 | 31 | onDeleted() { 32 | this.log('device deleted'); 33 | this._client.unregisterDevice(this.entityId); 34 | } 35 | 36 | onCapabilityButton( value, opts, callback ) { 37 | this._client.turnOnOff(this.entityId, true); 38 | callback( null ); 39 | } 40 | 41 | onEntityUpdate(data) { 42 | // nothing to update 43 | } 44 | } 45 | 46 | module.exports = SceneDevice; -------------------------------------------------------------------------------- /drivers/scene/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SceneDriver extends Homey.Driver { 6 | 7 | onPairListDevices(ata, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let scenes = client.getScenes(); 11 | 12 | callback(null, scenes); 13 | } 14 | 15 | } 16 | 17 | module.exports = SceneDriver; -------------------------------------------------------------------------------- /drivers/script/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /drivers/script/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/script/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/script/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/script/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/script/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class ScriptDevice extends Homey.Device { 6 | 7 | onInit() { 8 | this._client = Homey.app.getClient(); 9 | 10 | this.entityId = this.getData().id; 11 | 12 | this.log('device init'); 13 | this.log('id:', this.entityId); 14 | this.log('name:', this.getName()); 15 | this.log('class:', this.getClass()); 16 | 17 | this._client.registerDevice(this.entityId, this); 18 | 19 | let entity = this._client.getEntity(this.entityId); 20 | if(entity) { 21 | this.onEntityUpdate(entity); 22 | } 23 | 24 | this.registerCapabilityListener('button', this.onCapabilityButton.bind(this)) 25 | } 26 | 27 | onAdded() { 28 | this.log('device added'); 29 | } 30 | 31 | onDeleted() { 32 | this.log('device deleted'); 33 | this._client.unregisterDevice(this.entityId); 34 | } 35 | 36 | onCapabilityButton( value, opts, callback ) { 37 | this._client.turnOnOff(this.entityId, true); 38 | callback( null ); 39 | } 40 | 41 | onEntityUpdate(data) { 42 | // nothing to update 43 | } 44 | } 45 | 46 | module.exports = ScriptDevice; -------------------------------------------------------------------------------- /drivers/script/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class ScriptDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let scripts = client.getScripts(); 11 | 12 | callback(null, scripts); 13 | } 14 | 15 | } 16 | 17 | module.exports = ScriptDriver; -------------------------------------------------------------------------------- /drivers/sensor/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/co2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 12 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_battery.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | device_battery_charge_outline_stroke 10 | Created with Sketch. 11 | 12 | 13 | 14 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_humidity.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 23 | 24 | 26 | 27 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_luminance.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 31 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_power.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xmlPP 78 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_pressure.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/measure_temperature.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/meter_power.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 21 | 22 | -------------------------------------------------------------------------------- /drivers/sensor/assets/icons/noise.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 12 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /drivers/sensor/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/sensor/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/sensor/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/sensor/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/sensor/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SensorDevice extends Homey.Device { 6 | 7 | onInit() { 8 | this._client = Homey.app.getClient(); 9 | 10 | this.entityId = this.getData().id; 11 | this.capability = this.getCapabilities()[0]; 12 | 13 | this.log('device init'); 14 | this.log('id:', this.entityId); 15 | this.log('name:', this.getName()); 16 | this.log('class:', this.getClass()); 17 | 18 | this._client.registerDevice(this.entityId, this); 19 | 20 | let entity = this._client.getEntity(this.entityId); 21 | if(entity) { 22 | this.onEntityUpdate(entity); 23 | } 24 | } 25 | 26 | onAdded() { 27 | this.log('device added'); 28 | } 29 | 30 | onDeleted() { 31 | this.log('device deleted'); 32 | this._client.unregisterDevice(this.entityId); 33 | } 34 | 35 | onEntityUpdate(data) { 36 | try { 37 | switch(this.capability) { 38 | case "measure_generic": 39 | this.setCapabilityValue(this.capability, data.state); 40 | break; 41 | default: 42 | this.setCapabilityValue(this.capability, parseFloat(data.state)); 43 | } 44 | 45 | } catch(ex) { 46 | this.log("error", ex); 47 | } 48 | } 49 | } 50 | 51 | module.exports = SensorDevice; -------------------------------------------------------------------------------- /drivers/sensor/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SensorDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let sensors = client.getSensors(); 11 | 12 | callback(null, sensors); 13 | } 14 | 15 | } 16 | 17 | module.exports = SensorDriver; -------------------------------------------------------------------------------- /drivers/switch/assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /drivers/switch/assets/icons/off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /drivers/switch/assets/icons/on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /drivers/switch/assets/images/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/switch/assets/images/large.jpg -------------------------------------------------------------------------------- /drivers/switch/assets/images/small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/drivers/switch/assets/images/small.jpg -------------------------------------------------------------------------------- /drivers/switch/device.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SwitchDevice extends Homey.Device { 6 | 7 | onInit() { 8 | this._client = Homey.app.getClient(); 9 | 10 | this.entityId = this.getData().id; 11 | 12 | this.log('device init'); 13 | this.log('id:', this.entityId); 14 | this.log('name:', this.getName()); 15 | this.log('class:', this.getClass()); 16 | 17 | this._client.registerDevice(this.entityId, this); 18 | 19 | let entity = this._client.getEntity(this.entityId); 20 | if(entity) { 21 | this.onEntityUpdate(entity); 22 | } 23 | 24 | this.registerCapabilityListener('onoff', this.onCapabilityOnoff.bind(this)) 25 | } 26 | 27 | onAdded() { 28 | this.log('device added'); 29 | } 30 | 31 | onDeleted() { 32 | this.log('device deleted'); 33 | this._client.unregisterDevice(this.entityId); 34 | } 35 | 36 | onCapabilityOnoff( value, opts, callback ) { 37 | this._client.turnOnOff(this.entityId, value); 38 | callback( null ); 39 | } 40 | 41 | onEntityUpdate(data) { 42 | if(data) { 43 | this.setCapabilityValue("onoff", data.state == "on"); 44 | } 45 | } 46 | } 47 | 48 | module.exports = SwitchDevice; -------------------------------------------------------------------------------- /drivers/switch/driver.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Homey = require('homey'); 4 | 5 | class SwitchDriver extends Homey.Driver { 6 | 7 | onPairListDevices(data, callback) { 8 | 9 | let client = Homey.app.getClient(); 10 | let switches = client.getSwitches(); 11 | 12 | callback(null, switches); 13 | } 14 | 15 | } 16 | 17 | module.exports = SwitchDriver; -------------------------------------------------------------------------------- /locales/en.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /locales/nl.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /node_modules/async-limiter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "node" 5 | script: npm run travis 6 | cache: 7 | yarn: true 8 | -------------------------------------------------------------------------------- /node_modules/async-limiter/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2017 Samuel Reed 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/coverage.json: -------------------------------------------------------------------------------- 1 | {"/Users/samuelreed/git/forks/async-throttle/index.js":{"path":"/Users/samuelreed/git/forks/async-throttle/index.js","s":{"1":1,"2":7,"3":1,"4":6,"5":6,"6":6,"7":6,"8":6,"9":6,"10":1,"11":1,"12":3,"13":13,"14":13,"15":13,"16":1,"17":19,"18":1,"19":45,"20":6,"21":39,"22":13,"23":13,"24":13,"25":13,"26":39,"27":18,"28":6,"29":6,"30":1,"31":6,"32":6,"33":6,"34":1,"35":13,"36":13,"37":1},"b":{"1":[1,6],"2":[6,5],"3":[6,5],"4":[6,39],"5":[13,26],"6":[18,21],"7":[6,0]},"f":{"1":7,"2":3,"3":13,"4":19,"5":45,"6":6,"7":13},"fnMap":{"1":{"name":"Queue","line":3,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":24}}},"2":{"name":"(anonymous_2)","line":22,"loc":{"start":{"line":22,"column":24},"end":{"line":22,"column":41}}},"3":{"name":"(anonymous_3)","line":23,"loc":{"start":{"line":23,"column":28},"end":{"line":23,"column":39}}},"4":{"name":"(anonymous_4)","line":31,"loc":{"start":{"line":31,"column":7},"end":{"line":31,"column":18}}},"5":{"name":"(anonymous_5)","line":36,"loc":{"start":{"line":36,"column":23},"end":{"line":36,"column":34}}},"6":{"name":"(anonymous_6)","line":55,"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":38}}},"7":{"name":"done","line":62,"loc":{"start":{"line":62,"column":0},"end":{"line":62,"column":16}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":14,"column":1}},"2":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}},"3":{"start":{"line":5,"column":4},"end":{"line":5,"column":30}},"4":{"start":{"line":8,"column":2},"end":{"line":8,"column":26}},"5":{"start":{"line":9,"column":2},"end":{"line":9,"column":53}},"6":{"start":{"line":10,"column":2},"end":{"line":10,"column":19}},"7":{"start":{"line":11,"column":2},"end":{"line":11,"column":17}},"8":{"start":{"line":12,"column":2},"end":{"line":12,"column":16}},"9":{"start":{"line":13,"column":2},"end":{"line":13,"column":31}},"10":{"start":{"line":16,"column":0},"end":{"line":20,"column":2}},"11":{"start":{"line":22,"column":0},"end":{"line":28,"column":3}},"12":{"start":{"line":23,"column":2},"end":{"line":27,"column":4}},"13":{"start":{"line":24,"column":4},"end":{"line":24,"column":75}},"14":{"start":{"line":25,"column":4},"end":{"line":25,"column":16}},"15":{"start":{"line":26,"column":4},"end":{"line":26,"column":24}},"16":{"start":{"line":30,"column":0},"end":{"line":34,"column":3}},"17":{"start":{"line":32,"column":4},"end":{"line":32,"column":43}},"18":{"start":{"line":36,"column":0},"end":{"line":53,"column":2}},"19":{"start":{"line":37,"column":2},"end":{"line":39,"column":3}},"20":{"start":{"line":38,"column":4},"end":{"line":38,"column":11}},"21":{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},"22":{"start":{"line":41,"column":4},"end":{"line":41,"column":32}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":19}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":20}},"25":{"start":{"line":44,"column":4},"end":{"line":44,"column":16}},"26":{"start":{"line":47,"column":2},"end":{"line":52,"column":3}},"27":{"start":{"line":48,"column":4},"end":{"line":51,"column":5}},"28":{"start":{"line":49,"column":6},"end":{"line":49,"column":30}},"29":{"start":{"line":50,"column":6},"end":{"line":50,"column":27}},"30":{"start":{"line":55,"column":0},"end":{"line":60,"column":2}},"31":{"start":{"line":56,"column":2},"end":{"line":59,"column":3}},"32":{"start":{"line":57,"column":4},"end":{"line":57,"column":22}},"33":{"start":{"line":58,"column":4},"end":{"line":58,"column":16}},"34":{"start":{"line":62,"column":0},"end":{"line":65,"column":1}},"35":{"start":{"line":63,"column":2},"end":{"line":63,"column":17}},"36":{"start":{"line":64,"column":2},"end":{"line":64,"column":14}},"37":{"start":{"line":67,"column":0},"end":{"line":67,"column":23}}},"branchMap":{"1":{"line":4,"type":"if","locations":[{"start":{"line":4,"column":2},"end":{"line":4,"column":2}},{"start":{"line":4,"column":2},"end":{"line":4,"column":2}}]},"2":{"line":8,"type":"binary-expr","locations":[{"start":{"line":8,"column":12},"end":{"line":8,"column":19}},{"start":{"line":8,"column":23},"end":{"line":8,"column":25}}]},"3":{"line":9,"type":"binary-expr","locations":[{"start":{"line":9,"column":21},"end":{"line":9,"column":40}},{"start":{"line":9,"column":44},"end":{"line":9,"column":52}}]},"4":{"line":37,"type":"if","locations":[{"start":{"line":37,"column":2},"end":{"line":37,"column":2}},{"start":{"line":37,"column":2},"end":{"line":37,"column":2}}]},"5":{"line":40,"type":"if","locations":[{"start":{"line":40,"column":2},"end":{"line":40,"column":2}},{"start":{"line":40,"column":2},"end":{"line":40,"column":2}}]},"6":{"line":47,"type":"if","locations":[{"start":{"line":47,"column":2},"end":{"line":47,"column":2}},{"start":{"line":47,"column":2},"end":{"line":47,"column":2}}]},"7":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":2},"end":{"line":56,"column":2}},{"start":{"line":56,"column":2},"end":{"line":56,"column":2}}]}}}} -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for async-throttle/ 5 | 6 | 7 | 8 | 13 | 14 | 15 |
16 |

Code coverage report for async-throttle/

17 |

18 | Statements: 100% (37 / 37)      19 | Branches: 92.86% (13 / 14)      20 | Functions: 100% (7 / 7)      21 | Lines: 100% (37 / 37)      22 | Ignored: none      23 |

24 |
All files » async-throttle/
25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
FileStatementsBranchesFunctionsLines
index.js100%(37 / 37)92.86%(13 / 14)100%(7 / 7)100%(37 / 37)
58 |
59 |
60 | 63 | 64 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for async-throttle/index.js 5 | 6 | 7 | 8 | 13 | 14 | 15 |
16 |

Code coverage report for async-throttle/index.js

17 |

18 | Statements: 100% (37 / 37)      19 | Branches: 92.86% (13 / 14)      20 | Functions: 100% (7 / 7)      21 | Lines: 100% (37 / 37)      22 | Ignored: none      23 |

24 |
All files » async-throttle/ » index.js
25 |
26 |
27 |

 28 | 
230 | 
1 29 | 2 30 | 3 31 | 4 32 | 5 33 | 6 34 | 7 35 | 8 36 | 9 37 | 10 38 | 11 39 | 12 40 | 13 41 | 14 42 | 15 43 | 16 44 | 17 45 | 18 46 | 19 47 | 20 48 | 21 49 | 22 50 | 23 51 | 24 52 | 25 53 | 26 54 | 27 55 | 28 56 | 29 57 | 30 58 | 31 59 | 32 60 | 33 61 | 34 62 | 35 63 | 36 64 | 37 65 | 38 66 | 39 67 | 40 68 | 41 69 | 42 70 | 43 71 | 44 72 | 45 73 | 46 74 | 47 75 | 48 76 | 49 77 | 50 78 | 51 79 | 52 80 | 53 81 | 54 82 | 55 83 | 56 84 | 57 85 | 58 86 | 59 87 | 60 88 | 61 89 | 62 90 | 63 91 | 64 92 | 65 93 | 66 94 | 67 95 | 68  96 |   97 | 1 98 | 7 99 | 1 100 |   101 |   102 | 6 103 | 6 104 | 6 105 | 6 106 | 6 107 | 6 108 |   109 |   110 | 1 111 |   112 |   113 |   114 |   115 |   116 | 1 117 | 3 118 | 13 119 | 13 120 | 13 121 |   122 |   123 |   124 | 1 125 |   126 | 19 127 |   128 |   129 |   130 | 1 131 | 45 132 | 6 133 |   134 | 39 135 | 13 136 | 13 137 | 13 138 | 13 139 |   140 |   141 | 39 142 | 18 143 | 6 144 | 6 145 |   146 |   147 |   148 |   149 | 1 150 | 6 151 | 6 152 | 6 153 |   154 |   155 |   156 | 1 157 | 13 158 | 13 159 |   160 |   161 | 1 162 |  
'use strict';
163 |  
164 | function Queue(options) {
165 |   if (!(this instanceof Queue)) {
166 |     return new Queue(options);
167 |   }
168 |  
169 |   options = options || {};
170 |   this.concurrency = options.concurrency || Infinity;
171 |   this.pending = 0;
172 |   this.jobs = [];
173 |   this.cbs = [];
174 |   this._done = done.bind(this);
175 | }
176 |  
177 | var arrayAddMethods = [
178 |   'push',
179 |   'unshift',
180 |   'splice'
181 | ];
182 |  
183 | arrayAddMethods.forEach(function(method) {
184 |   Queue.prototype[method] = function() {
185 |     var methodResult = Array.prototype[method].apply(this.jobs, arguments);
186 |     this._run();
187 |     return methodResult;
188 |   };
189 | });
190 |  
191 | Object.defineProperty(Queue.prototype, 'length', {
192 |   get: function() {
193 |     return this.pending + this.jobs.length;
194 |   }
195 | });
196 |  
197 | Queue.prototype._run = function() {
198 |   if (this.pending === this.concurrency) {
199 |     return;
200 |   }
201 |   if (this.jobs.length) {
202 |     var job = this.jobs.shift();
203 |     this.pending++;
204 |     job(this._done);
205 |     this._run();
206 |   }
207 |  
208 |   if (this.pending === 0) {
209 |     while (this.cbs.length !== 0) {
210 |       var cb = this.cbs.pop();
211 |       process.nextTick(cb);
212 |     }
213 |   }
214 | };
215 |  
216 | Queue.prototype.onDone = function(cb) {
217 |   Eif (typeof cb === 'function') {
218 |     this.cbs.push(cb);
219 |     this._run();
220 |   }
221 | };
222 |  
223 | function done() {
224 |   this.pending--;
225 |   this._run();
226 | }
227 |  
228 | module.exports = Queue;
229 |  
231 | 232 |
233 | 236 | 237 | 244 | 245 | 246 | 247 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | } 4 | body { 5 | font-family: Helvetica Neue, Helvetica,Arial; 6 | font-size: 10pt; 7 | } 8 | div.header, div.footer { 9 | background: #eee; 10 | padding: 1em; 11 | } 12 | div.header { 13 | z-index: 100; 14 | position: fixed; 15 | top: 0; 16 | border-bottom: 1px solid #666; 17 | width: 100%; 18 | } 19 | div.footer { 20 | border-top: 1px solid #666; 21 | } 22 | div.body { 23 | margin-top: 10em; 24 | } 25 | div.meta { 26 | font-size: 90%; 27 | text-align: center; 28 | } 29 | h1, h2, h3 { 30 | font-weight: normal; 31 | } 32 | h1 { 33 | font-size: 12pt; 34 | } 35 | h2 { 36 | font-size: 10pt; 37 | } 38 | pre { 39 | font-family: Consolas, Menlo, Monaco, monospace; 40 | margin: 0; 41 | padding: 0; 42 | line-height: 1.3; 43 | font-size: 14px; 44 | -moz-tab-size: 2; 45 | -o-tab-size: 2; 46 | tab-size: 2; 47 | } 48 | 49 | div.path { font-size: 110%; } 50 | div.path a:link, div.path a:visited { color: #000; } 51 | table.coverage { border-collapse: collapse; margin:0; padding: 0 } 52 | 53 | table.coverage td { 54 | margin: 0; 55 | padding: 0; 56 | color: #111; 57 | vertical-align: top; 58 | } 59 | table.coverage td.line-count { 60 | width: 50px; 61 | text-align: right; 62 | padding-right: 5px; 63 | } 64 | table.coverage td.line-coverage { 65 | color: #777 !important; 66 | text-align: right; 67 | border-left: 1px solid #666; 68 | border-right: 1px solid #666; 69 | } 70 | 71 | table.coverage td.text { 72 | } 73 | 74 | table.coverage td span.cline-any { 75 | display: inline-block; 76 | padding: 0 5px; 77 | width: 40px; 78 | } 79 | table.coverage td span.cline-neutral { 80 | background: #eee; 81 | } 82 | table.coverage td span.cline-yes { 83 | background: #b5d592; 84 | color: #999; 85 | } 86 | table.coverage td span.cline-no { 87 | background: #fc8c84; 88 | } 89 | 90 | .cstat-yes { color: #111; } 91 | .cstat-no { background: #fc8c84; color: #111; } 92 | .fstat-no { background: #ffc520; color: #111 !important; } 93 | .cbranch-no { background: yellow !important; color: #111; } 94 | 95 | .cstat-skip { background: #ddd; color: #111; } 96 | .fstat-skip { background: #ddd; color: #111 !important; } 97 | .cbranch-skip { background: #ddd !important; color: #111; } 98 | 99 | .missing-if-branch { 100 | display: inline-block; 101 | margin-right: 10px; 102 | position: relative; 103 | padding: 0 4px; 104 | background: black; 105 | color: yellow; 106 | } 107 | 108 | .skip-if-branch { 109 | display: none; 110 | margin-right: 10px; 111 | position: relative; 112 | padding: 0 4px; 113 | background: #ccc; 114 | color: white; 115 | } 116 | 117 | .missing-if-branch .typ, .skip-if-branch .typ { 118 | color: inherit !important; 119 | } 120 | 121 | .entity, .metric { font-weight: bold; } 122 | .metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; } 123 | .metric small { font-size: 80%; font-weight: normal; color: #666; } 124 | 125 | div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; } 126 | div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; } 127 | div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; } 128 | div.coverage-summary th.file { border-right: none !important; } 129 | div.coverage-summary th.pic { border-left: none !important; text-align: right; } 130 | div.coverage-summary th.pct { border-right: none !important; } 131 | div.coverage-summary th.abs { border-left: none !important; text-align: right; } 132 | div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; } 133 | div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; } 134 | div.coverage-summary td.file { border-left: 1px solid #666; white-space: nowrap; } 135 | div.coverage-summary td.pic { min-width: 120px !important; } 136 | div.coverage-summary a:link { text-decoration: none; color: #000; } 137 | div.coverage-summary a:visited { text-decoration: none; color: #777; } 138 | div.coverage-summary a:hover { text-decoration: underline; } 139 | div.coverage-summary tfoot td { border-top: 1px solid #666; } 140 | 141 | div.coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | div.coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | div.coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | 155 | .high { background: #b5d592 !important; } 156 | .medium { background: #ffe87c !important; } 157 | .low { background: #fc8c84 !important; } 158 | 159 | span.cover-fill, span.cover-empty { 160 | display:inline-block; 161 | border:1px solid #444; 162 | background: white; 163 | height: 12px; 164 | } 165 | span.cover-fill { 166 | background: #ccc; 167 | border-right: 1px solid #444; 168 | } 169 | span.cover-empty { 170 | background: white; 171 | border-left: none; 172 | } 173 | span.cover-full { 174 | border-right: none !important; 175 | } 176 | pre.prettyprint { 177 | border: none !important; 178 | padding: 0 !important; 179 | margin: 0 !important; 180 | } 181 | .com { color: #999 !important; } 182 | .ignore-none { color: #999; font-weight: normal; } 183 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 13 | 14 | 15 |
16 |

Code coverage report for All files

17 |

18 | Statements: 100% (37 / 37)      19 | Branches: 92.86% (13 / 14)      20 | Functions: 100% (7 / 7)      21 | Lines: 100% (37 / 37)      22 | Ignored: none      23 |

24 |
25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
FileStatementsBranchesFunctionsLines
async-throttle/100%(37 / 37)92.86%(13 / 14)100%(7 / 7)100%(37 / 37)
58 |
59 |
60 | 63 | 64 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogro82/io.homeassistant/45d9f62e5e0fc76becdc61c7d6ac1064d5712e7a/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary table'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | el = getNthColumn(i).querySelector('.sorter'); 136 | if (el.addEventListener) { 137 | el.addEventListener('click', ithSorter(i)); 138 | } else { 139 | el.attachEvent('onclick', ithSorter(i)); 140 | } 141 | } 142 | } 143 | } 144 | // adds sorting functionality to the UI 145 | return function () { 146 | if (!getTable()) { 147 | return; 148 | } 149 | cols = loadColumns(); 150 | loadData(cols); 151 | addSortIndicators(); 152 | enableUI(); 153 | }; 154 | })(); 155 | 156 | window.addEventListener('load', addSorting); 157 | -------------------------------------------------------------------------------- /node_modules/async-limiter/coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/Users/samuelreed/git/forks/async-throttle/index.js 3 | FN:3,Queue 4 | FN:22,(anonymous_2) 5 | FN:23,(anonymous_3) 6 | FN:31,(anonymous_4) 7 | FN:36,(anonymous_5) 8 | FN:55,(anonymous_6) 9 | FN:62,done 10 | FNF:7 11 | FNH:7 12 | FNDA:7,Queue 13 | FNDA:3,(anonymous_2) 14 | FNDA:13,(anonymous_3) 15 | FNDA:19,(anonymous_4) 16 | FNDA:45,(anonymous_5) 17 | FNDA:6,(anonymous_6) 18 | FNDA:13,done 19 | DA:3,1 20 | DA:4,7 21 | DA:5,1 22 | DA:8,6 23 | DA:9,6 24 | DA:10,6 25 | DA:11,6 26 | DA:12,6 27 | DA:13,6 28 | DA:16,1 29 | DA:22,1 30 | DA:23,3 31 | DA:24,13 32 | DA:25,13 33 | DA:26,13 34 | DA:30,1 35 | DA:32,19 36 | DA:36,1 37 | DA:37,45 38 | DA:38,6 39 | DA:40,39 40 | DA:41,13 41 | DA:42,13 42 | DA:43,13 43 | DA:44,13 44 | DA:47,39 45 | DA:48,18 46 | DA:49,6 47 | DA:50,6 48 | DA:55,1 49 | DA:56,6 50 | DA:57,6 51 | DA:58,6 52 | DA:62,1 53 | DA:63,13 54 | DA:64,13 55 | DA:67,1 56 | LF:37 57 | LH:37 58 | BRDA:4,1,0,1 59 | BRDA:4,1,1,6 60 | BRDA:8,2,0,6 61 | BRDA:8,2,1,5 62 | BRDA:9,3,0,6 63 | BRDA:9,3,1,5 64 | BRDA:37,4,0,6 65 | BRDA:37,4,1,39 66 | BRDA:40,5,0,13 67 | BRDA:40,5,1,26 68 | BRDA:47,6,0,18 69 | BRDA:47,6,1,21 70 | BRDA:56,7,0,6 71 | BRDA:56,7,1,0 72 | BRF:14 73 | BRH:13 74 | end_of_record 75 | -------------------------------------------------------------------------------- /node_modules/async-limiter/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function Queue(options) { 4 | if (!(this instanceof Queue)) { 5 | return new Queue(options); 6 | } 7 | 8 | options = options || {}; 9 | this.concurrency = options.concurrency || Infinity; 10 | this.pending = 0; 11 | this.jobs = []; 12 | this.cbs = []; 13 | this._done = done.bind(this); 14 | } 15 | 16 | var arrayAddMethods = [ 17 | 'push', 18 | 'unshift', 19 | 'splice' 20 | ]; 21 | 22 | arrayAddMethods.forEach(function(method) { 23 | Queue.prototype[method] = function() { 24 | var methodResult = Array.prototype[method].apply(this.jobs, arguments); 25 | this._run(); 26 | return methodResult; 27 | }; 28 | }); 29 | 30 | Object.defineProperty(Queue.prototype, 'length', { 31 | get: function() { 32 | return this.pending + this.jobs.length; 33 | } 34 | }); 35 | 36 | Queue.prototype._run = function() { 37 | if (this.pending === this.concurrency) { 38 | return; 39 | } 40 | if (this.jobs.length) { 41 | var job = this.jobs.shift(); 42 | this.pending++; 43 | job(this._done); 44 | this._run(); 45 | } 46 | 47 | if (this.pending === 0) { 48 | while (this.cbs.length !== 0) { 49 | var cb = this.cbs.pop(); 50 | process.nextTick(cb); 51 | } 52 | } 53 | }; 54 | 55 | Queue.prototype.onDone = function(cb) { 56 | if (typeof cb === 'function') { 57 | this.cbs.push(cb); 58 | this._run(); 59 | } 60 | }; 61 | 62 | function done() { 63 | this.pending--; 64 | this._run(); 65 | } 66 | 67 | module.exports = Queue; 68 | -------------------------------------------------------------------------------- /node_modules/async-limiter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "async-limiter@~1.0.0", 3 | "_id": "async-limiter@1.0.0", 4 | "_inBundle": false, 5 | "_integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", 6 | "_location": "/async-limiter", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "async-limiter@~1.0.0", 12 | "name": "async-limiter", 13 | "escapedName": "async-limiter", 14 | "rawSpec": "~1.0.0", 15 | "saveSpec": null, 16 | "fetchSpec": "~1.0.0" 17 | }, 18 | "_requiredBy": [ 19 | "/ws" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", 22 | "_shasum": "78faed8c3d074ab81f22b4e985d79e8738f720f8", 23 | "_spec": "async-limiter@~1.0.0", 24 | "_where": "/home/rob/Development/Solutions/homey/io.home-assistant/node_modules/ws", 25 | "author": { 26 | "name": "Samuel Reed" 27 | }, 28 | "bugs": { 29 | "url": "https://github.com/strml/async-limiter/issues" 30 | }, 31 | "bundleDependencies": false, 32 | "dependencies": {}, 33 | "deprecated": false, 34 | "description": "asynchronous function queue with adjustable concurrency", 35 | "devDependencies": { 36 | "coveralls": "^2.11.2", 37 | "eslint": "^4.6.1", 38 | "eslint-plugin-mocha": "^4.11.0", 39 | "intelli-espower-loader": "^1.0.1", 40 | "istanbul": "^0.3.2", 41 | "mocha": "^3.5.2", 42 | "power-assert": "^1.4.4" 43 | }, 44 | "homepage": "https://github.com/strml/async-limiter#readme", 45 | "keywords": [ 46 | "throttle", 47 | "async", 48 | "limiter", 49 | "asynchronous", 50 | "job", 51 | "task", 52 | "concurrency", 53 | "concurrent" 54 | ], 55 | "license": "MIT", 56 | "name": "async-limiter", 57 | "repository": { 58 | "type": "git", 59 | "url": "git+https://github.com/strml/async-limiter.git" 60 | }, 61 | "scripts": { 62 | "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls", 63 | "example": "node example", 64 | "lint": "eslint .", 65 | "test": "mocha --R intelli-espower-loader test/", 66 | "travis": "npm run lint && npm run coverage" 67 | }, 68 | "version": "1.0.0" 69 | } 70 | -------------------------------------------------------------------------------- /node_modules/async-limiter/readme.md: -------------------------------------------------------------------------------- 1 | # Async-Limiter 2 | 3 | A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue). 4 | 5 | [![npm](http://img.shields.io/npm/v/async-limiter.svg?style=flat-square)](http://www.npmjs.org/async-limiter) 6 | [![tests](https://img.shields.io/travis/STRML/async-limiter.svg?style=flat-square&branch=master)](https://travis-ci.org/STRML/async-limiter) 7 | [![coverage](https://img.shields.io/coveralls/STRML/async-limiter.svg?style=flat-square&branch=master)](https://coveralls.io/r/STRML/async-limiter) 8 | 9 | This module exports a class `Limiter` that implements some of the `Array` API. 10 | Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods. 11 | 12 | ## Motivation 13 | 14 | Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when 15 | run at infinite concurrency. 16 | 17 | In this case, it is actually faster, and takes far less memory, to limit concurrency. 18 | 19 | This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would 20 | make this module faster or lighter, but new functionality is not desired. 21 | 22 | Style should confirm to nodejs/node style. 23 | 24 | ## Example 25 | 26 | ``` javascript 27 | var Limiter = require('async-limiter') 28 | 29 | var t = new Limiter({concurrency: 2}); 30 | var results = [] 31 | 32 | // add jobs using the familiar Array API 33 | t.push(function (cb) { 34 | results.push('two') 35 | cb() 36 | }) 37 | 38 | t.push( 39 | function (cb) { 40 | results.push('four') 41 | cb() 42 | }, 43 | function (cb) { 44 | results.push('five') 45 | cb() 46 | } 47 | ) 48 | 49 | t.unshift(function (cb) { 50 | results.push('one') 51 | cb() 52 | }) 53 | 54 | t.splice(2, 0, function (cb) { 55 | results.push('three') 56 | cb() 57 | }) 58 | 59 | // Jobs run automatically. If you want a callback when all are done, 60 | // call 'onDone()'. 61 | t.onDone(function () { 62 | console.log('all done:', results) 63 | }) 64 | ``` 65 | 66 | ## Zlib Example 67 | 68 | ```js 69 | const zlib = require('zlib'); 70 | const Limiter = require('async-limiter'); 71 | 72 | const message = {some: "data"}; 73 | const payload = new Buffer(JSON.stringify(message)); 74 | 75 | // Try with different concurrency values to see how this actually 76 | // slows significantly with higher concurrency! 77 | // 78 | // 5: 1398.607ms 79 | // 10: 1375.668ms 80 | // Infinity: 4423.300ms 81 | // 82 | const t = new Limiter({concurrency: 5}); 83 | function deflate(payload, cb) { 84 | t.push(function(done) { 85 | zlib.deflate(payload, function(err, buffer) { 86 | done(); 87 | cb(err, buffer); 88 | }); 89 | }); 90 | } 91 | 92 | console.time('deflate'); 93 | for(let i = 0; i < 30000; ++i) { 94 | deflate(payload, function (err, buffer) {}); 95 | } 96 | q.onDone(function() { 97 | console.timeEnd('deflate'); 98 | }); 99 | ``` 100 | 101 | ## Install 102 | 103 | `npm install async-limiter` 104 | 105 | ## Test 106 | 107 | `npm test` 108 | 109 | ## API 110 | 111 | ### `var t = new Limiter([opts])` 112 | Constructor. `opts` may contain inital values for: 113 | * `q.concurrency` 114 | 115 | ## Instance methods 116 | 117 | ### `q.onDone(fn)` 118 | `fn` will be called once and only once, when the queue is empty. 119 | 120 | ## Instance methods mixed in from `Array` 121 | Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). 122 | ### `q.push(element1, ..., elementN)` 123 | ### `q.unshift(element1, ..., elementN)` 124 | ### `q.splice(index , howMany[, element1[, ...[, elementN]]])` 125 | 126 | ## Properties 127 | ### `q.concurrency` 128 | Max number of jobs the queue should process concurrently, defaults to `Infinity`. 129 | 130 | ### `q.length` 131 | Jobs pending + jobs to process (readonly). 132 | 133 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/auth.d.ts: -------------------------------------------------------------------------------- 1 | export declare type AuthData = { 2 | hassUrl: string; 3 | clientId: string; 4 | expires: number; 5 | refresh_token: string; 6 | access_token: string; 7 | expires_in: number; 8 | }; 9 | export declare type SaveTokensFunc = (data: AuthData | null) => void; 10 | export declare type LoadTokensFunc = () => Promise; 11 | export declare type getAuthOptions = { 12 | hassUrl?: string; 13 | clientId?: string; 14 | redirectUrl?: string; 15 | saveTokens?: SaveTokensFunc; 16 | loadTokens?: LoadTokensFunc; 17 | }; 18 | export declare const genClientId: () => string; 19 | export declare const genExpires: (expires_in: number) => number; 20 | export declare class Auth { 21 | private _saveTokens?; 22 | data: AuthData; 23 | constructor(data: AuthData, saveTokens?: SaveTokensFunc); 24 | readonly wsUrl: string; 25 | readonly accessToken: string; 26 | readonly expired: boolean; 27 | /** 28 | * Refresh the access token. 29 | */ 30 | refreshAccessToken(): Promise; 31 | /** 32 | * Revoke the refresh & access tokens. 33 | */ 34 | revoke(): Promise; 35 | } 36 | export declare function getAuth(options?: getAuthOptions): Promise; 37 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/collection.d.ts: -------------------------------------------------------------------------------- 1 | import { Store } from "./store"; 2 | import { Connection } from "./connection"; 3 | import { UnsubscribeFunc } from "./types"; 4 | export declare type Collection = { 5 | state: State; 6 | refresh(): Promise; 7 | subscribe(subscriber: (state: State) => void): UnsubscribeFunc; 8 | }; 9 | export declare const getCollection: (conn: Connection, key: string, fetchCollection: (conn: Connection) => Promise, subscribeUpdates?: ((conn: Connection, store: Store) => Promise) | undefined) => Collection; 10 | export declare const createCollection: (key: string, fetchCollection: (conn: Connection) => Promise, subscribeUpdates: ((conn: Connection, store: Store) => Promise) | undefined, conn: Connection, onChange: (state: State) => void) => UnsubscribeFunc; 11 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/commands.d.ts: -------------------------------------------------------------------------------- 1 | import { Connection } from "./connection"; 2 | import { HassEntity, HassServices, HassConfig } from "./types"; 3 | export declare const getStates: (connection: Connection) => Promise; 4 | export declare const getServices: (connection: Connection) => Promise; 5 | export declare const getConfig: (connection: Connection) => Promise; 6 | export declare const getUser: (connection: Connection) => Promise; 7 | export declare const callService: (connection: Connection, domain: string, service: string, serviceData?: object | undefined) => Promise<{}>; 8 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/config.d.ts: -------------------------------------------------------------------------------- 1 | import { HassConfig, UnsubscribeFunc } from "./types"; 2 | import { Connection } from "./connection"; 3 | export declare const subscribeConfig: (conn: Connection, onChange: (state: HassConfig) => void) => UnsubscribeFunc; 4 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/connection.d.ts: -------------------------------------------------------------------------------- 1 | import { ConnectionOptions, MessageBase } from "./types"; 2 | export declare type ConnectionEventListener = (conn: Connection, eventData?: any) => void; 3 | declare type Events = "ready" | "disconnected" | "reconnect-error"; 4 | declare type SubscribeEventCommmandInFlight = { 5 | resolve: (result?: any) => void; 6 | reject: (err: any) => void; 7 | eventCallback: (ev: any) => void; 8 | eventType?: string; 9 | unsubscribe: () => Promise; 10 | }; 11 | declare type CommandWithAnswerInFlight = { 12 | resolve: (result?: any) => void; 13 | reject: (err: any) => void; 14 | }; 15 | declare type CommandInFlight = SubscribeEventCommmandInFlight | CommandWithAnswerInFlight; 16 | export declare class Connection { 17 | options: ConnectionOptions; 18 | commandId: number; 19 | commands: { 20 | [commandId: number]: CommandInFlight; 21 | }; 22 | eventListeners: { 23 | [eventType: string]: ConnectionEventListener[]; 24 | }; 25 | closeRequested: boolean; 26 | socket: WebSocket; 27 | constructor(socket: WebSocket, options: ConnectionOptions); 28 | setSocket(socket: WebSocket): void; 29 | addEventListener(eventType: Events, callback: ConnectionEventListener): void; 30 | removeEventListener(eventType: Events, callback: ConnectionEventListener): void; 31 | fireEvent(eventType: Events, eventData?: any): void; 32 | close(): void; 33 | subscribeEvents(eventCallback: (ev: EventType) => void, eventType?: string): Promise<() => Promise>; 34 | ping(): Promise<{}>; 35 | sendMessage(message: MessageBase, commandId?: number): void; 36 | sendMessagePromise(message: MessageBase): Promise; 37 | private _handleMessage; 38 | private _handleClose; 39 | private _genCmdId; 40 | } 41 | export {}; 42 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/entities.d.ts: -------------------------------------------------------------------------------- 1 | import { HassEntities, UnsubscribeFunc } from "./types"; 2 | import { Connection } from "./connection"; 3 | export declare const entitiesColl: (conn: Connection) => import("./collection").Collection; 4 | export declare const subscribeEntities: (conn: Connection, onChange: (state: HassEntities) => void) => UnsubscribeFunc; 5 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/errors.d.ts: -------------------------------------------------------------------------------- 1 | export declare const ERR_CANNOT_CONNECT = 1; 2 | export declare const ERR_INVALID_AUTH = 2; 3 | export declare const ERR_CONNECTION_LOST = 3; 4 | export declare const ERR_HASS_HOST_REQUIRED = 4; 5 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ConnectionOptions } from "./types"; 2 | import { Connection } from "./connection"; 3 | export * from "./auth"; 4 | export * from "./collection"; 5 | export * from "./connection"; 6 | export * from "./config"; 7 | export * from "./services"; 8 | export * from "./entities"; 9 | export * from "./errors"; 10 | export * from "./types"; 11 | export * from "./commands"; 12 | export declare function createConnection(options?: Partial): Promise; 13 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/messages.d.ts: -------------------------------------------------------------------------------- 1 | import { Error } from "./types"; 2 | export declare function auth(accessToken: string): { 3 | type: string; 4 | access_token: string; 5 | }; 6 | export declare function states(): { 7 | type: string; 8 | }; 9 | export declare function config(): { 10 | type: string; 11 | }; 12 | export declare function services(): { 13 | type: string; 14 | }; 15 | export declare function user(): { 16 | type: string; 17 | }; 18 | declare type ServiceCallMessage = { 19 | type: "call_service"; 20 | domain: string; 21 | service: string; 22 | service_data?: object; 23 | }; 24 | export declare function callService(domain: string, service: string, serviceData?: object): ServiceCallMessage; 25 | declare type SubscribeEventMessage = { 26 | type: "subscribe_events"; 27 | event_type?: string; 28 | }; 29 | export declare function subscribeEvents(eventType?: string): SubscribeEventMessage; 30 | export declare function unsubscribeEvents(subscription: number): { 31 | type: string; 32 | subscription: number; 33 | }; 34 | export declare function ping(): { 35 | type: string; 36 | }; 37 | export declare function error(code: Error, message: string): { 38 | type: string; 39 | success: boolean; 40 | error: { 41 | code: Error; 42 | message: string; 43 | }; 44 | }; 45 | export {}; 46 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/services.d.ts: -------------------------------------------------------------------------------- 1 | import { HassServices, UnsubscribeFunc } from "./types"; 2 | import { Connection } from "./connection"; 3 | export declare const subscribeServices: (conn: Connection, onChange: (state: HassServices) => void) => UnsubscribeFunc; 4 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/socket.d.ts: -------------------------------------------------------------------------------- 1 | import { ConnectionOptions } from "./types"; 2 | export declare function createSocket(options: ConnectionOptions): Promise; 3 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/store.d.ts: -------------------------------------------------------------------------------- 1 | import { UnsubscribeFunc } from "./types"; 2 | declare type Listener = (state: State) => void; 3 | declare type Action = (state: State, ...args: any[]) => Partial | Promise> | null; 4 | declare type BoundAction = (...args: any[]) => void; 5 | export declare type Store = { 6 | state: State | undefined; 7 | action(action: Action): BoundAction; 8 | setState(update: Partial, overwrite?: boolean): void; 9 | subscribe(listener: Listener): UnsubscribeFunc; 10 | }; 11 | export declare const createStore: (state?: State | undefined) => Store; 12 | export {}; 13 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/types.d.ts: -------------------------------------------------------------------------------- 1 | import { Auth } from "./auth"; 2 | export declare type Error = 1 | 2 | 3 | 4; 3 | export declare type UnsubscribeFunc = () => void; 4 | export declare type ConnectionOptions = { 5 | setupRetry: number; 6 | auth?: Auth; 7 | createSocket: (options: ConnectionOptions) => Promise; 8 | }; 9 | export declare type MessageBase = { 10 | id?: number; 11 | type: string; 12 | [key: string]: any; 13 | }; 14 | export declare type HassEventBase = { 15 | origin: string; 16 | time_fired: string; 17 | context: { 18 | id: string; 19 | user_id: string; 20 | }; 21 | }; 22 | export declare type HassEvent = HassEventBase & { 23 | event_type: string; 24 | data: { 25 | [key: string]: any; 26 | }; 27 | }; 28 | export declare type StateChangedEvent = HassEventBase & { 29 | event_type: "state_changed"; 30 | data: { 31 | entity_id: string; 32 | new_state: HassEntity | null; 33 | old_state: HassEntity | null; 34 | }; 35 | }; 36 | export declare type HassConfig = { 37 | latitude: number; 38 | longitude: number; 39 | elevation: number; 40 | unit_system: { 41 | length: string; 42 | mass: string; 43 | volume: string; 44 | temperature: string; 45 | }; 46 | location_name: string; 47 | time_zone: string; 48 | components: string[]; 49 | config_dir: string; 50 | whitelist_external_dirs: string[]; 51 | version: string; 52 | }; 53 | export declare type HassEntityBase = { 54 | entity_id: string; 55 | state: string; 56 | last_changed: string; 57 | last_updated: string; 58 | attributes: HassEntityAttributeBase; 59 | }; 60 | export declare type HassEntityAttributeBase = { 61 | friendly_name?: string; 62 | unit_of_measurement?: string; 63 | icon?: string; 64 | entity_picture?: string; 65 | supported_features?: number; 66 | hidden: boolean; 67 | assumed_state?: boolean; 68 | device_class?: string; 69 | }; 70 | export declare type HassEntity = HassEntityBase & { 71 | attributes: { 72 | [key: string]: any; 73 | }; 74 | }; 75 | export declare type HassEntities = { 76 | [entity_id: string]: HassEntity; 77 | }; 78 | export declare type HassService = { 79 | description: string; 80 | fields: { 81 | [field_name: string]: { 82 | description: string; 83 | example: string; 84 | }; 85 | }; 86 | }; 87 | export declare type HassDomainServices = { 88 | [service_name: string]: HassService; 89 | }; 90 | export declare type HassServices = { 91 | [domain: string]: HassDomainServices; 92 | }; 93 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/dist/util.d.ts: -------------------------------------------------------------------------------- 1 | export declare function parseQuery(queryString: string): T; 2 | -------------------------------------------------------------------------------- /node_modules/home-assistant-js-websocket/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "home-assistant-js-websocket", 3 | "_id": "home-assistant-js-websocket@3.2.4", 4 | "_inBundle": false, 5 | "_integrity": "sha512-DaHpWIjJFLwTWNbHeGSCEUsbeyLUWAyWUgsYkiVWxzbfm+vqC5YaLNRu+Ma64SQYh5yGSYr7h25p2hip1GvyhQ==", 6 | "_location": "/home-assistant-js-websocket", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "home-assistant-js-websocket", 12 | "name": "home-assistant-js-websocket", 13 | "escapedName": "home-assistant-js-websocket", 14 | "rawSpec": "", 15 | "saveSpec": null, 16 | "fetchSpec": "latest" 17 | }, 18 | "_requiredBy": [ 19 | "#USER", 20 | "/" 21 | ], 22 | "_resolved": "https://registry.npmjs.org/home-assistant-js-websocket/-/home-assistant-js-websocket-3.2.4.tgz", 23 | "_shasum": "0c4212e6ac57b60ed939aa420253994e4f9f0bef", 24 | "_spec": "home-assistant-js-websocket", 25 | "_where": "/home/rob/Development/Solutions/homey/io.home-assistant", 26 | "amdName": "HAWS", 27 | "author": { 28 | "name": "Paulus Schoutsen", 29 | "email": "paulus@paulusschoutsen.nl" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/home-assistant/home-assistant-js-websocket/issues" 33 | }, 34 | "bundleDependencies": false, 35 | "dependencies": {}, 36 | "deprecated": false, 37 | "description": "Home Assistant websocket client", 38 | "devDependencies": { 39 | "@types/mocha": "^5.2.5", 40 | "husky": "^1.1.3", 41 | "lint-staged": "^8.0.4", 42 | "microbundle": "^0.7.0", 43 | "mocha": "^5.1.1", 44 | "prettier": "^1.14.3", 45 | "ts-node": "^7.0.1" 46 | }, 47 | "files": [ 48 | "dist" 49 | ], 50 | "homepage": "https://github.com/home-assistant/home-assistant-js-websocket#readme", 51 | "husky": { 52 | "hooks": { 53 | "pre-commit": "lint-staged" 54 | } 55 | }, 56 | "license": "Apache-2.0", 57 | "lint-staged": { 58 | "*.{ts,js,json,css,md}": [ 59 | "prettier --write", 60 | "git add" 61 | ] 62 | }, 63 | "main": "dist/haws.umd.js", 64 | "module": "dist/haws.es.js", 65 | "name": "home-assistant-js-websocket", 66 | "repository": { 67 | "url": "git+https://github.com/home-assistant/home-assistant-js-websocket.git", 68 | "type": "git" 69 | }, 70 | "scripts": { 71 | "build": "microbundle --target browser", 72 | "prepublishOnly": "rm -rf dist && microbundle --target browser && npm test", 73 | "test": "mocha test/*.spec.ts", 74 | "watch": "microbundle watch" 75 | }, 76 | "sideEffects": false, 77 | "source": "lib/index.ts", 78 | "types": "dist/index.d.ts", 79 | "version": "3.2.4" 80 | } 81 | -------------------------------------------------------------------------------- /node_modules/ws/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011 Einar Otto Stangvik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/ws/browser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function() { 4 | throw new Error( 5 | 'ws does not work in the browser. Browser clients must use the native ' + 6 | 'WebSocket object' 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /node_modules/ws/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebSocket = require('./lib/websocket'); 4 | 5 | WebSocket.Server = require('./lib/websocket-server'); 6 | WebSocket.Receiver = require('./lib/receiver'); 7 | WebSocket.Sender = require('./lib/sender'); 8 | 9 | module.exports = WebSocket; 10 | -------------------------------------------------------------------------------- /node_modules/ws/lib/buffer-util.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Merges an array of buffers into a new buffer. 5 | * 6 | * @param {Buffer[]} list The array of buffers to concat 7 | * @param {Number} totalLength The total length of buffers in the list 8 | * @return {Buffer} The resulting buffer 9 | * @public 10 | */ 11 | function concat(list, totalLength) { 12 | const target = Buffer.allocUnsafe(totalLength); 13 | var offset = 0; 14 | 15 | for (var i = 0; i < list.length; i++) { 16 | const buf = list[i]; 17 | buf.copy(target, offset); 18 | offset += buf.length; 19 | } 20 | 21 | return target; 22 | } 23 | 24 | /** 25 | * Masks a buffer using the given mask. 26 | * 27 | * @param {Buffer} source The buffer to mask 28 | * @param {Buffer} mask The mask to use 29 | * @param {Buffer} output The buffer where to store the result 30 | * @param {Number} offset The offset at which to start writing 31 | * @param {Number} length The number of bytes to mask. 32 | * @public 33 | */ 34 | function _mask(source, mask, output, offset, length) { 35 | for (var i = 0; i < length; i++) { 36 | output[offset + i] = source[i] ^ mask[i & 3]; 37 | } 38 | } 39 | 40 | /** 41 | * Unmasks a buffer using the given mask. 42 | * 43 | * @param {Buffer} buffer The buffer to unmask 44 | * @param {Buffer} mask The mask to use 45 | * @public 46 | */ 47 | function _unmask(buffer, mask) { 48 | // Required until https://github.com/nodejs/node/issues/9006 is resolved. 49 | const length = buffer.length; 50 | for (var i = 0; i < length; i++) { 51 | buffer[i] ^= mask[i & 3]; 52 | } 53 | } 54 | 55 | try { 56 | const bufferUtil = require('bufferutil'); 57 | const bu = bufferUtil.BufferUtil || bufferUtil; 58 | 59 | module.exports = { 60 | mask(source, mask, output, offset, length) { 61 | if (length < 48) _mask(source, mask, output, offset, length); 62 | else bu.mask(source, mask, output, offset, length); 63 | }, 64 | unmask(buffer, mask) { 65 | if (buffer.length < 32) _unmask(buffer, mask); 66 | else bu.unmask(buffer, mask); 67 | }, 68 | concat 69 | }; 70 | } catch (e) /* istanbul ignore next */ { 71 | module.exports = { concat, mask: _mask, unmask: _unmask }; 72 | } 73 | -------------------------------------------------------------------------------- /node_modules/ws/lib/constants.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | BINARY_TYPES: ['nodebuffer', 'arraybuffer', 'fragments'], 5 | GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', 6 | kStatusCode: Symbol('status-code'), 7 | kWebSocket: Symbol('websocket'), 8 | EMPTY_BUFFER: Buffer.alloc(0), 9 | NOOP: () => {} 10 | }; 11 | -------------------------------------------------------------------------------- /node_modules/ws/lib/event-target.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Class representing an event. 5 | * 6 | * @private 7 | */ 8 | class Event { 9 | /** 10 | * Create a new `Event`. 11 | * 12 | * @param {String} type The name of the event 13 | * @param {Object} target A reference to the target to which the event was dispatched 14 | */ 15 | constructor(type, target) { 16 | this.target = target; 17 | this.type = type; 18 | } 19 | } 20 | 21 | /** 22 | * Class representing a message event. 23 | * 24 | * @extends Event 25 | * @private 26 | */ 27 | class MessageEvent extends Event { 28 | /** 29 | * Create a new `MessageEvent`. 30 | * 31 | * @param {(String|Buffer|ArrayBuffer|Buffer[])} data The received data 32 | * @param {WebSocket} target A reference to the target to which the event was dispatched 33 | */ 34 | constructor(data, target) { 35 | super('message', target); 36 | 37 | this.data = data; 38 | } 39 | } 40 | 41 | /** 42 | * Class representing a close event. 43 | * 44 | * @extends Event 45 | * @private 46 | */ 47 | class CloseEvent extends Event { 48 | /** 49 | * Create a new `CloseEvent`. 50 | * 51 | * @param {Number} code The status code explaining why the connection is being closed 52 | * @param {String} reason A human-readable string explaining why the connection is closing 53 | * @param {WebSocket} target A reference to the target to which the event was dispatched 54 | */ 55 | constructor(code, reason, target) { 56 | super('close', target); 57 | 58 | this.wasClean = target._closeFrameReceived && target._closeFrameSent; 59 | this.reason = reason; 60 | this.code = code; 61 | } 62 | } 63 | 64 | /** 65 | * Class representing an open event. 66 | * 67 | * @extends Event 68 | * @private 69 | */ 70 | class OpenEvent extends Event { 71 | /** 72 | * Create a new `OpenEvent`. 73 | * 74 | * @param {WebSocket} target A reference to the target to which the event was dispatched 75 | */ 76 | constructor(target) { 77 | super('open', target); 78 | } 79 | } 80 | 81 | /** 82 | * Class representing an error event. 83 | * 84 | * @extends Event 85 | * @private 86 | */ 87 | class ErrorEvent extends Event { 88 | /** 89 | * Create a new `ErrorEvent`. 90 | * 91 | * @param {Object} error The error that generated this event 92 | * @param {WebSocket} target A reference to the target to which the event was dispatched 93 | */ 94 | constructor(error, target) { 95 | super('error', target); 96 | 97 | this.message = error.message; 98 | this.error = error; 99 | } 100 | } 101 | 102 | /** 103 | * This provides methods for emulating the `EventTarget` interface. It's not 104 | * meant to be used directly. 105 | * 106 | * @mixin 107 | */ 108 | const EventTarget = { 109 | /** 110 | * Register an event listener. 111 | * 112 | * @param {String} method A string representing the event type to listen for 113 | * @param {Function} listener The listener to add 114 | * @public 115 | */ 116 | addEventListener(method, listener) { 117 | if (typeof listener !== 'function') return; 118 | 119 | function onMessage(data) { 120 | listener.call(this, new MessageEvent(data, this)); 121 | } 122 | 123 | function onClose(code, message) { 124 | listener.call(this, new CloseEvent(code, message, this)); 125 | } 126 | 127 | function onError(error) { 128 | listener.call(this, new ErrorEvent(error, this)); 129 | } 130 | 131 | function onOpen() { 132 | listener.call(this, new OpenEvent(this)); 133 | } 134 | 135 | if (method === 'message') { 136 | onMessage._listener = listener; 137 | this.on(method, onMessage); 138 | } else if (method === 'close') { 139 | onClose._listener = listener; 140 | this.on(method, onClose); 141 | } else if (method === 'error') { 142 | onError._listener = listener; 143 | this.on(method, onError); 144 | } else if (method === 'open') { 145 | onOpen._listener = listener; 146 | this.on(method, onOpen); 147 | } else { 148 | this.on(method, listener); 149 | } 150 | }, 151 | 152 | /** 153 | * Remove an event listener. 154 | * 155 | * @param {String} method A string representing the event type to remove 156 | * @param {Function} listener The listener to remove 157 | * @public 158 | */ 159 | removeEventListener(method, listener) { 160 | const listeners = this.listeners(method); 161 | 162 | for (var i = 0; i < listeners.length; i++) { 163 | if (listeners[i] === listener || listeners[i]._listener === listener) { 164 | this.removeListener(method, listeners[i]); 165 | } 166 | } 167 | } 168 | }; 169 | 170 | module.exports = EventTarget; 171 | -------------------------------------------------------------------------------- /node_modules/ws/lib/validation.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | try { 4 | const isValidUTF8 = require('utf-8-validate'); 5 | 6 | exports.isValidUTF8 = 7 | typeof isValidUTF8 === 'object' 8 | ? isValidUTF8.Validation.isValidUTF8 // utf-8-validate@<3.0.0 9 | : isValidUTF8; 10 | } catch (e) /* istanbul ignore next */ { 11 | exports.isValidUTF8 = () => true; 12 | } 13 | 14 | /** 15 | * Checks if a status code is allowed in a close frame. 16 | * 17 | * @param {Number} code The status code 18 | * @return {Boolean} `true` if the status code is valid, else `false` 19 | * @public 20 | */ 21 | exports.isValidStatusCode = (code) => { 22 | return ( 23 | (code >= 1000 && 24 | code <= 1013 && 25 | code !== 1004 && 26 | code !== 1005 && 27 | code !== 1006) || 28 | (code >= 3000 && code <= 4999) 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /node_modules/ws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "ws", 3 | "_id": "ws@6.1.2", 4 | "_inBundle": false, 5 | "_integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", 6 | "_location": "/ws", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "ws", 12 | "name": "ws", 13 | "escapedName": "ws", 14 | "rawSpec": "", 15 | "saveSpec": null, 16 | "fetchSpec": "latest" 17 | }, 18 | "_requiredBy": [ 19 | "#USER", 20 | "/" 21 | ], 22 | "_resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", 23 | "_shasum": "3cc7462e98792f0ac679424148903ded3b9c3ad8", 24 | "_spec": "ws", 25 | "_where": "/home/rob/Development/Solutions/homey/io.home-assistant", 26 | "author": { 27 | "name": "Einar Otto Stangvik", 28 | "email": "einaros@gmail.com", 29 | "url": "http://2x.io" 30 | }, 31 | "browser": "browser.js", 32 | "bugs": { 33 | "url": "https://github.com/websockets/ws/issues" 34 | }, 35 | "bundleDependencies": false, 36 | "dependencies": { 37 | "async-limiter": "~1.0.0" 38 | }, 39 | "deprecated": false, 40 | "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js", 41 | "devDependencies": { 42 | "benchmark": "~2.1.4", 43 | "bufferutil": "~4.0.0", 44 | "eslint": "~5.9.0", 45 | "eslint-config-prettier": "~3.3.0", 46 | "eslint-plugin-prettier": "~3.0.0", 47 | "mocha": "~5.2.0", 48 | "nyc": "~13.1.0", 49 | "prettier": "~1.15.2", 50 | "prettylint": "~1.0.0", 51 | "utf-8-validate": "~5.0.0" 52 | }, 53 | "files": [ 54 | "browser.js", 55 | "index.js", 56 | "lib/*.js" 57 | ], 58 | "homepage": "https://github.com/websockets/ws", 59 | "keywords": [ 60 | "HyBi", 61 | "Push", 62 | "RFC-6455", 63 | "WebSocket", 64 | "WebSockets", 65 | "real-time" 66 | ], 67 | "license": "MIT", 68 | "main": "index.js", 69 | "name": "ws", 70 | "repository": { 71 | "type": "git", 72 | "url": "git+https://github.com/websockets/ws.git" 73 | }, 74 | "scripts": { 75 | "integration": "npm run lint && mocha test/*.integration.js", 76 | "lint": "eslint . --ignore-path .gitignore && prettylint '**/*.{json,md}' --ignore-path .gitignore", 77 | "test": "npm run lint && nyc --reporter=html --reporter=text mocha test/*.test.js" 78 | }, 79 | "version": "6.1.2" 80 | } 81 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": true, 3 | "lockfileVersion": 1, 4 | "dependencies": { 5 | "async-limiter": { 6 | "version": "1.0.0", 7 | "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", 8 | "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" 9 | }, 10 | "home-assistant-js-websocket": { 11 | "version": "3.2.4", 12 | "resolved": "https://registry.npmjs.org/home-assistant-js-websocket/-/home-assistant-js-websocket-3.2.4.tgz", 13 | "integrity": "sha512-DaHpWIjJFLwTWNbHeGSCEUsbeyLUWAyWUgsYkiVWxzbfm+vqC5YaLNRu+Ma64SQYh5yGSYr7h25p2hip1GvyhQ==" 14 | }, 15 | "ws": { 16 | "version": "6.1.2", 17 | "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", 18 | "integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", 19 | "requires": { 20 | "async-limiter": "~1.0.0" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /settings/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 |
20 | Connection settings 21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 |
30 | 31 |
32 | Connection state 33 |
34 |
Failed to connect...
35 |
Successfully connected
36 |
37 |
38 | 39 | 40 | 41 | 81 | 82 | 83 | --------------------------------------------------------------------------------