Skip to content

native nodejs library for communicating with switcher smart water heater

License

Notifications You must be signed in to change notification settings

johnathanvidu/switcher-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

switcher-js

switcher-js is a native nodejs library for controling switcher smart water heater.
It is a native javascript port of a wonderful python script (can be found here) created as a result of the extensive work which has been done by Aviad Golan (@AviadGolan) and Shai rod (@NightRang3r).
It is a work in progress and there is still a lot of work left to do.

I built it according to my specific needs and my specific device. If any issue arises, please feel free to open an issue and I'll do my best to help.
Current supported devices known to work with switcher-js:

  • Switcher V3 (Switcher touch) - FW V1.51

Installation

Use npm to install switcher-js.

npm install switcher-js

Usage

const Switcher = require('switcher-js').Switcher;

var switcher = new Switcher('device-id', 'device-ip', 'phone-id', 'device-pass', 'log function');

To use the auto discover functionallity use:

const Switcher = require('switcher-js').Switcher;

var proxy = Switcher.discover('phone-id', 'device-pass', 'log function');

proxy.on('ready', (switcher) => {
    switcher.turn_on(); // switcher is a new initialized instance of Switcher class
});

discover will emit a ready event when auto discovery completed.

phone-id (optional) - will be defaulted to 0000 if no value provided
device-pass (optional) - will be defaulted to 00000000 if no value provided

Examples:

const Switcher = require('switcher-js').Switcher;

var switcher = new Switcher('device-id', 'device-ip', 'phone-id', 'device-pass', 'log function');

switcher.on('state', (state) => { // state is the new switcher state 
    
});
switcher.on('error', (error) => {

});

switcher.turn_on();   // turns switcher on
switcher.turn_on(15); // turns switcher on for 15 minutes
switcher.turn_off();  // turns switcher off
switcher.close();     // closes any dangling connections safely

switcher-js exposes two states for convenience

const switcher = require('switcher-js');

switcher.ON = 0
switcher.OFF = 1

Contributing

Pull requests are more than welcome. For major changes, please open an issue first to discuss what you would like to change. Even coding tips and standards are welcome, I have very limited experience with javascript, so there's a lot of things I don't know are cleaner or more standarized in the industry.

License

MIT

About

native nodejs library for communicating with switcher smart water heater

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published