Closed Silkjaer closed 3 years ago
I added a "PatioHeater.js" to the services folder and edited Lightbulb to support external heaters (Solamagic heater with Somfy IO control). Then i used the config to "forceType" the heater to "PatioHeater".
var Log, Service, Characteristic;
var AbstractService = require('./AbstractService');
var { Command, ExecutionState } = require('../overkiz-api');
class PatioHeater extends AbstractService {
constructor (homebridge, log, device, config) {
super(homebridge, log, device);
Log = log;
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;
this.service = new Service.Lightbulb(device.getName());
this.onState = this.service.getCharacteristic(Characteristic.On);
this.onState.on('set', this.setOn.bind(this));
if(this.device.widget.includes('DimmerExteriorHeating')) {
this.levelState = this.service.addCharacteristic(Characteristic.Brightness);
this.levelState.on('set', this.setLevel.bind(this));
}
}
/**
* Triggered when Homekit try to modify the Characteristic.On
**/
setOn(value, callback) {
var commands = [];
switch(this.device.widget) {
case 'DimmerExteriorHeating':
if(value == 1) { callback(); break; } // Ignore 'on' command for DimmerExteriorHeating as homekit send 'on' + 'brightness'
default:
commands.push(new Command(value ? 'on' : 'off'));
break;
}
if(commands.length) {
this.device.executeCommand(commands, function(status, error, data) {}.bind(this), callback);
}
}
/**
* Triggered when Homekit try to modify the Characteristic.Brightness
**/
setLevel(value, callback) {
var commands = new Command('setLevel', 100 - value);
if(commands) {
this.device.executeCommand(commands, function(status, error, data) {}.bind(this), callback);
}
}
onStateUpdate(name, value) {
var levelState = null;
switch(name) {
case 'core:LevelState':
levelState = 100 - value; // reverse
break;
}
if (this.levelState != null && levelState != null) {
this.levelState.updateValue(levelState);
if(levelState == 0) {
this.onState.updateValue(0);
}
else {
this.onState.updateValue(1);
}
}
}
}
module.exports = PatioHeater
I have the exact same problem, but I don't fully understand you solution.
1) Yes
2) I didn't make changes to Lightbulb, but I based the above code on the Lightbulb implementation.
3) In the config, add this snippet with the name of your heater, to force the type from the default "Switch" to the new type "PatioHeater".
"forceType": {
"Name of the heater": "PatioHeater"
},
How can I copy PatioHeater.js to the service folder. My homebridge is running on a Rasberry PI and I am trying to use the command scp PatioHeater.js pi@192.168.87.33:/usr/local/lib/node_modules/homebridge-tahoma/services from MacOS, but then it askes for a password and the one I use for HomeBridge does not work.
Do you ssh to the pi? Then you need to use the same username and password for scp.
I fixed it by using scp PatioHeater.js pi@192.168.87.33: to get it to the PI and then use sudo cp PatioHeater.js /usr/local/lib/node_modules/homebridge-tahoma/services/ to copy it to services. Now it works real fine - should be standard part of the npm module.
Hi,
Could you please expose your config with following steps to let me know implements your changes in next releases.
Thank you.
Hi,
ExteriorHeatingSystem works perfectly but is appearing as a Switch. Our awning exterior heater can be adjusted in heating level, so it would be awesome to have it appear as a light instead, that can be adjusted in brightness (heating level).
Let me know what information is needed and what I can do to supply it.
Thanks!