kasa-smart-hub
Version:
Virtual Smart Hub for TP-Link Kasa Smart Home
106 lines (75 loc) • 3.28 kB
Markdown
[](https://circleci.com/gh/blackflux/kasa-smart-hub)
[](https://coveralls.io/github/blackflux/kasa-smart-hub?branch=master)
[](https://dependabot.com)
[](https://david-dm.org/blackflux/kasa-smart-hub)
[](https://www.npmjs.com/package/kasa-smart-hub)
[](https://www.npmjs.com/package/kasa-smart-hub)
[](https://github.com/semantic-release/semantic-release)
[](https://github.com/blackflux/js-gardener)
Virtual Smart Hub for TP-Link Kasa Smart Home
Designed to be run on a LAN server, e.g. on a [Raspberry Pi](https://en.wikipedia.org/wiki/Raspberry_Pi).
Install as global npm packages. Then create configuration file and start with
```
kasa-smart-hub /path/to/config.json
```
Configuration can be in multiple formats. Most likely you want to use `config.js` or `config.json`.
Where events logs are stored
Object that contains "linked" switches that are always executed together.
Used to automatically switch off devices
Default fallback timer. Can be set to zero to disable.
```js
import path from 'path';
import fs from 'smart-fs';
export default {
logFile: path.join(fs.dirname(import.meta.url), 'kasa-logs.txt'),
links: {
'kitchen-lights': [
// when either of these is switched on / off the other one will also switch on / off
'Kitchen Counter Lights',
'Kitchen Ceiling Light'
]
},
timer: {
__default: 8 * 60 * 60, // switch off everything after eight hours
'Bathroom Fan': 60 * 60 // switch off after one hour
},
on: {
'Plant Light': ['We 21:00'] // switch on every Wednesday at 9pm
},
off: {
TV: ['02:00'] // switch off every day at 2am
},
timezone: 'America/Vancouver'
};
```
Ensure you are running a recent node version. Install with
`npm install -g kasa-smart-hub`
Place
```
[]
WorkingDirectory=/home/pi/kasa-smart-hub
ExecStart=kasa-smart-hub start /home/pi/kasa-smart-hub/config.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=
User=pi
Group=pi
[]
WantedBy=multi-user.target
```
in `/etc/systemd/system/kasa-smart-hub.service`.
Ensure it is readable/writeable/executable by the appropriate user.
Now enable service with `sudo systemctl enable kasa-smart-hub`
To start the service right away run `sudo systemctl start kasa-smart-hub`
This project relies on [tplink-smarthome-api](https://github.com/plasticrake/tplink-smarthome-api). Documentation for that project can be found [here](https://freesoft.dev/program/63196852#startDiscovery).