Backend to control Ikea TRADFRI from IFTTT
This project is based on google_home_starter by Kyle Peacock.
Using this project you can controll your IKEA lights using the Google Home/Assistant. The names of the lightbulbs and groups should be set up in the IKEA app. As there is no way to make subgroups, you can hack around it by naming lighbulbs in a similar fashion. For example:
Living Room
.Couch 1
, Couch 2
, Lamp 1
.turn all the living room lights
.turn on the couch lights
which is a subgroup of the living room lights.If you haven't already, install git and node.js on your device.
Fork or clone this repository onto your device.
In your console, run npm install
to install the required components.
Run touch .env
to create your hidden, gitignored environment config file.
Generate a preshared key for your application by running node get_key.js
In .env, configure your environment as follows:
DEV=
TRUE
if you are on desktop, or FALSE
if you are on your raspberry piPORT=
The port that the server will listen on.PASS=
Whatever you want the password to your API to beHUBIP=
The IP to your IKEA Tradfri hubAPIUSER=
The user/identity used to the connect to the hubAPIKEY=
The password/psk used to connect to the hubRun npm start
to launch the server
Test your API
http://[IPADDRESS]:[PORT]/api/:operation/:what/:state?password=[PASS]
[IPADDRESS]
- the internet accessible IP address used to access the API. This is usually the public IP address of your router.[PORT]
- the internet accessible PORT used to access the API. You usually have to forward this from your router to the host running this package.[PASS]
- the password you defined in the .env filecurl
such as curl -i -X POST http://[IPADDRESS]:[PORT]/api/turn/all/on?password=[PASS]
(this should turn on all the lights)Setup the IFTTT commands:
this
use Google Assistant
that
use webhook
Turn the $ lights on
=> http://[IPADDRESS]:[PORT]/api/turn/{{TextField}}/on?password=[PASS]
Turn the $ lights off
=> http://[IPADDRESS]:[PORT]/api/turn/{{TextField}}/off?password=[PASS]
Set the $ lights to #
=> http://[IPADDRESS]:[PORT]/api/dim/{{TextField}}/{{NumberField}}?password=[PASS]
Set the light color to $
=> http://[IPADDRESS]:[PORT]/api/color/all/{{TextField}}?password=[PASS]
Set the $ light temperature to #
=> http://[IPADDRESS]:[PORT]/api/temp/{{TextField}}/{{NumberField}}?password=[PASS]
Run the project at startup:
cd /home/pi/node_tradfri_ifttt && nohup npm start &
to your /etc/rc.local