Open jonbev opened 7 years ago
The underlying Hive api isn't very intuitive when it comes to setting the water to always off, it looks like the setState method can't do this but there is an onOffState method which can. After some investigating I found that the following code will do what you want.
var Hive = require('bg-hive-api');
var hive = new Hive('your login', 'your password');
var HotWaterControl = require('bg-hive-api/hotWaterControl');
hive.on('login', function (context) {
// Create an instance of the hot water controller
var water = new HotWaterControl(context);
water.once('accepted', function (response) {
console.log('Water is off');
hive.Logout();
});
water.Call({
'onOffState': {
'PUT': {
'onOffState': 'OFF'
}
}
});
});
//Log in
hive.Login();
Counter-intuitively setting the onOffState to On will set the water back to Scheduled therefore to explicitly set the water to on use
water.SetState(water.Mode.Manual);
And back to schedule
water.SetState(water.Mode.Schedule);
as per the documentation. I'll need to handle this is in code so the setState method works as expected.
Thanks for getting back to me, really appreciate your work on this.
I can set it to manual or schedule but if I try and turn it off the call just seems to be ignored.
I have tried -
hotwater.SetState(hotwater.State.Off); hotwater.SetState(hotwater.Mode.Off); hotwater.SetState(''OFF");
All of these seem to be ignored, no events are fired.
Thanks.