- rename
preset_save.json
topreset.json
- create
config.json
{
"ip":"lightbulb ip"
}
- create DialogFlow agent
- Go to Settings ⚙ > Export and Import > Restore from zip using the
SmartBulb.zip
this directory. - run Ngrok on port 8000
- Copy ngrok link
- Back in Dialogflow Console > Fulfullment > Enable Webhook.
- Paste the URL into the URL field > Save. done!
module.exports.change_state = function(state, time, brightness) {
console.log(state, time, brightness);
light.send({
'smartlife.iot.smartbulb.lightingservice': {
'transition_light_state': {
'on_off': state,
'transition_period': time,
'brightness': brightness
}
}
})
.then(response => {
console.log(response)
})
.catch(e => console.error(e))
}
Here method to change state by API, take 3 parameters: state (0/1), time (how much time should be a transition) and brightness (0-100)
In server.js
in method javascript app.post()
big switch case, wich takes parameters from post-request body for find solution, after finding use javascript change_state(s, t, b)
or something else
Another 2 types of methods or changing preset.json
, wich keep your preset settings, or
- find current brightness by
javascript .infoBrightness()
- changing brightness for 10% up or down from current