I'm using Raspberry Pi 2 with RaZberry module.
I've been using openremotehelpers module for HTTP POST to get or set values.
I have created Virtual Thermostat, the default module that came with z-way-server.
Virtual thermostat is linked to a switch and a sensor that turns my cv/boiler on or off, depending on the temperature.
Now I wanted to set the level of this virtual thermostat with HTTP POST commands, that part is working.
All i have to do is opening the following url:
Code: Select all
http://192.168.1.30:8083/OpenRemote/SetVirtualThermostatLevel/ThermostatDevice_11/22
Here is the URL i've added to set the level of the virtual device.
File: /opt/z-way-server/automation/modules/OpenRemoteHelpers/index.js
Code: Select all
case "SetVirtualThermostatLevel":
var level = I;
return this.controller.devices.get(N).set("metrics:level",level);
When firing that URL it changes my virtual thermostats temperature but doesn't flip a switch, only after a few minutes.
I've found the reason why but i can't seem to figure this this part out.
File: /opt/z-way-server/automation/modules/ThermostatDevice/index.js has the following method ( self.checkTemp(); ) that runs when the level of the virtual thermostat has changed, sadly it only fires this method when you're changing it inside the UI of Z-way OR when you wait for a few minutes (2-8 min).
The method i'm talking about is called: self.checkTemp(); like i mentioned before.
Code: Select all
ThermostatDevice.prototype.checkTemp = function () {
var vDevSwitch = this.controller.devices.get(this.config.switch),
vDevSensor = this.controller.devices.get(this.config.sensor),
vDev = this.vDev;
if (vDevSwitch && vDevSensor && vDev) {
if ((vDevSensor.get('metrics:level') + this.config.hysteresis < vDev.get('metrics:level')) && (vDevSwitch.get('metrics:level') == "off" && this.config.heaton || vDevSwitch.get('metrics:level') == "on" && !this.config.heaton)) {
vDevSwitch.performCommand(this.config.heaton ? "on" : "off");
}
if ((vDevSensor.get('metrics:level') - this.config.hysteresis > vDev.get('metrics:level')) && (vDevSwitch.get('metrics:level') == "on" && this.config.heaton || vDevSwitch.get('metrics:level') == "off" && !this.config.heaton)) {
vDevSwitch.performCommand(this.config.heaton ? "off" : "on");
}
}
}
Is it even possible for a method/function to be called from inside another module?