Code Monkey home page Code Monkey logo

hwl-api's Introduction

Home Wizard Lite RESTFUL Proxy API (Node.JS)

HomeWizard Lite Proxy API, built for integrating cheap HomeWizard Lite smartplugs into Home Assistant for example, freeing the user from the dreadful HWL Android or iOS app.

Installation

$ git clone https://github.com/basvanrooten/hwl-api
$ npm install
$ npm start
$ node index.js

The API depends on environment variables. Make sure to configure the bold variables, as these have no default.

Key Type Value
PORT number Port on which the API will listen (default: 3000)
HWL_USERNAME string HomeWizard Lite App Username
HWL_PASSWORD string HomeWizard Lite App Password
SMARTPLUG_ID string ID of the Internet Connected Smartplug. GET this ID from /api/smartplug
MIN_DIMMING_VALUE number The API supports dimmers. Some dimmers have a certain minimum threshold. When you request the API to go below the minimum dimming value, it'll instead turn off the light. (default: 1)
CACHE_TTL number Default expiration time for cache objects in seconds. Currently only in use for caching session-tokens from HWL. (default: 1800)
LOGLEVEL string Tracer Logger Level (default: warn)

Deploying

  • The API should be deployed on a local network and shouldn't be accessible over the interwebs, because it currently has no built-in authentication. It is always possible to configure HTTP Basic Authentication.
  • The API should have access to homewizard.com and its subdomains.

Using the included Dockerfile, it is also possible to run this API inside a container.

Endpoints

Method URL Description Example Request Example Response
GET /api/test/session Returns valid session key (Only necessary for testing) { "session": "string" }
GET /api/test/communication Returns status 200 when API can connect to Google to verify internet connectivity
GET /api/plug Returns all registered plugs *
GET /api/smartplug Returns info about your internet connected smartplug. (Tip: Use this to determine the ID of your smartplug. Use the id property.) *
GET /api/plug/:plugID Returns true or false for is_active state of a plug specified by plugID { "is_active": false }
POST /api/plug/:plugID [DIMMER] Change dimmer state when request body contains "type": "dimmer" and "value": number. When value is below MIN_DIMMING_VALUE, the dimmer will switch off. Returns is_active state. { "type": "dimmer", "value": 75 } { "is_active": true }
[SWITCH] Switches plug when request body contains "type": "switch" and "value": "on/off". Returns is_active state { "type": "switch", "value": "on" } { "is_active": true }

* Try this yourself. Response contains a bunch of useful info and does not fit needly in this table.

Contribution

This project was started by an IT-student as a small 2 day project to improve home-automation by enabling Home Assistant to control HomeWizard Lite plugs. Development will continue when I need more features. Contribution is appreciated.

hwl-api's People

Contributors

basvanrooten avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hwl-api's Issues

Integration via HACS?

Been looking for an integration exactly like this one to combine our Home Wizard Lite (Smartwares) setup with Home Assistant.
However, unsure how to implement your code.
Is there a way to import it trough HACS?

Thanks

Smartplug / plug ID

Thank you for releasing this! Exactly what I was looking for.

I'm a bit confused by the endpoint /api/act/smartplug/:smartPlugID/plug/:plugID. What constitutes the smartplug ID and plug ID? Using the registered plug IDs of the hub and plug I only get an error.

My request is in this format
curl -H "Content-Type: application/json" -X POST -d '{"action":"on"}' http://192.168.1.6:3000/api/act/smartplug/[HUB ID]/plug/[PLUG ID]

Thanks,
M

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.