UPdate:
data for room temperature seams frozen since i’ve edited the otgw.coffee file.
-
OTGW all data to Pimatic
-
Hi all,
I’ve found some more usefull info which I’ve used in my settings
my otgw.coffee:module.exports = (env) -> Promise = env.require 'bluebird' assert = env.require 'cassert' _ = env.require 'lodash' OTGWConnection = require 'OTGW-Control' Promise.promisifyAll(OTGWConnection.prototype) M = env.matcher settled = (promise) -> Promise.settle([promise]) class OTGWThermostatPlugin extends env.plugins.Plugin init: (app, @framework, @config) => # Promise that is resolved when the connection is established @_lastAction = new Promise( (resolve, reject) => @otgw = new OTGWConnection(@config.host, @config.port) @otgw.once("connected", resolve) @otgw.once('error', reject) return ).timeout(60000).catch( (error) -> env.logger.error "Error on connecting to OTGW relay: #{error.message}" env.logger.debug error.stack return ) @otgw.on('error', (error) => env.logger.error "connection error: #{error}" env.logger.debug error.stack ) @otgw.on("room_temperature", (data) => env.logger.debug "got room_temperature: ", data ) @otgw.on("remote_override_setpoint", (data) => env.logger.debug "got remote_override_setpoint: ", data ) @otgw.on("flame_status" , (data) => env.logger.debug "Flame status: ", data ) deviceConfigDef = require("./device-config-schema") @framework.deviceManager.registerDeviceClass("OTGWHeatingThermostat", { configDef: deviceConfigDef.OTGWHeatingThermostat, createCallback: (config, lastState) -> new OTGWHeatingThermostat(config, lastState) }) @framework.deviceManager.registerDeviceClass("OTGWMainThermostat", { configDef: deviceConfigDef.OTGWMainThermostat, createCallback: (config, lastState) -> new OTGWMainThermostat(config, lastState) }) @framework.deviceManager.registerDeviceClass("OTGWThermostat", { configDef: deviceConfigDef.OTGWThermostat, createCallback: (config) -> new OTGWThermostat(config) }) @framework.deviceManager.registerDeviceClass("OTGWMainThermostat1", { configDef: deviceConfigDef.OTGWMainThermostat1, createCallback: (config, lastState) -> new OTGWMainThermostat1(config, lastState) }) # @framework.deviceManager.registerDeviceClass("MaxContactSensor", { # configDef: deviceConfigDef.MaxContactSensor, # createCallback: (config, lastState) -> new MaxContactSensor(config, lastState) # }) # @framework.deviceManager.registerDeviceClass("MaxCube", { # configDef: deviceConfigDef.MaxCube, # createCallback: (config, lastState) -> new MaxCube(config, lastState) # }) #setTemperatureSetpoint: (rfAddress, mode, value) -> # setTemperatureSetpoint(mode,value) setTemperatureSetpoint: (mode, value) -> @_lastAction = settled(@_lastAction).then( => @otgw.setTemperatureAsync(mode, value) ) return @_lastAction plugin = new OTGWThermostatPlugin class OTGWThermostat extends env.devices.Device _fault = false _chmode = false _dhwmode = false _flame = false _coolingstatus = false _ch2mode = false _diag = false _chenable = false _dhwenable = false _coolingenable = false _otcstate = false _ch2enable = false; attributes: Flame: description: "Flame status" type: "boolean" CentralHeatingMode: description: "Central Heating Mode" type: "boolean" Fault: description: "Fault indication" type: "boolean" DomesticHotWaterMode: description: "Domestic Hot Water Mode" type: "boolean" CoolingStatus: description: "Cooling Status" type: "boolean" CentralHeating2Mode: description: "Central Heating 2 Mode" type: "boolean" Diagnostics: description: "Diagnostics" type: "boolean" CentralHeatingEnable: description: "Central Heating Enable" type: "boolean" DomesticHotWaterEnable: description: "Domestic Hot Water Enable" type: "boolean" CoolingEnable: description: "Cooling Enable" type: "boolean" OTCState: description: "OTC State" type: "boolean" CentralHeating2Enable: description: "Central Heating 2 Enable" type: "boolean" constructor: (@config) -> @id = @config.id @name = @config.name plugin.otgw.on("flame_status" , (data) => if data.length = 16 @_setFault(@_bitToBool(data.slice(15,16))) @_setCHMode(@_bitToBool(data.slice(14,15))) @_setDHWMode(@_bitToBool(data.slice(13,14))) @_setFlame(@_bitToBool(data.slice(12,13))) @_setCoolingStatus(@_bitToBool(data.slice(11,12))) @_setCH2Mode(@_bitToBool(data.slice(10,11))) @_setDiagnostics(@_bitToBool(data.slice(9,10))) @_setCHEnable(@_bitToBool(data.slice(8,9))) @_setDHWEnable(@_bitToBool(data.slice(7,8))) @_setCoolingEnable(@_bitToBool(data.slice(6,7))) @_setOTCState(@_bitToBool(data.slice(5,6))) @_setCH2Enable(@_bitToBool(data.slice(4,5))) ) super() #Getters getFlame: () -> return Promise.resolve @_flame getCentralHeatingMode: () -> return Promise.resolve @_chmode getFault: () -> return Promise.resolve @_fault getDomesticHotWaterMode: () -> return Promise.resolve @_dhwmode getCoolingStatus: () -> return Promise.resolve @_coolingstatus getCentralHeating2Mode: () -> return Promise.resolve @_ch2mode getDiagnostics: () -> return Promise.resolve @_diag getCentralHeatingEnable: () -> return Promise.resolve @_chenable getDomesticHotWaterEnable: () -> return Promise.resolve @_dhwenable getCoolingEnable: () -> return Promise.resolve @_coolingenable getOTCState: () -> return Promise.resolve @_otcstate getCentralHeating2Enable: () -> return Promise.resolve @_ch2enable #Setters _setFlame: (state) -> if @_flame isnt state @_flame = state @emit 'Flame', state _setCHMode: (state) -> if @_chmode isnt state @_chmode = state @emit 'CentralHeatingMode', state _setFault: (state) -> if @_fault isnt state @_fault = state @emit 'Fault', state _setDHWMode: (state) -> if @_dhwmode isnt state @_dhwmode = state @emit 'DomesticHotWaterMode', state _setCoolingStatus: (state) -> if @_coolingstatus isnt state @_coolingstatus = state @emit 'CoolingStatus', state _setCH2Mode: (state) -> if @_ch2mode isnt state @_ch2mode = state @emit 'CentralHeating2Mode', state _setDiagnostics: (state) -> if @_diag isnt state @_diag = state @emit 'Diagnostics', state _setCHEnable: (state) -> if @_chenable isnt state @_chenable = state @emit 'CentralHeatingEnable', state _setDHWEnable: (state) -> if @_dhwenable isnt state @_dhwenable = state @emit 'DomesticHotWaterEnable', state _setCoolingEnable: (state) -> if @_coolingenable isnt state @_coolingenable = state @emit 'CoolingEnable', state _setOTCState: (state) -> if @_otcstate isnt state @_otcstate = state @emit 'OTCState', state _setCH2Enable: (state) -> if @_ch2enable isnt state @_ch2enable = state @emit 'CentralHeating2Enable', state #Functions _bitToBool: (value) -> return (value is "1") class OTGWHeatingThermostat extends env.devices.HeatingThermostat constructor: (@config, lastState) -> @id = @config.id @name = @config.name @_temperatureSetpoint = lastState?.temperatureSetpoint?.value @_mode = lastState?.mode?.value or "auto" @_battery = lastState?.battery?.value or "ok" @_lastSendTime = 0 plugin.otgw.on("room_setpoint", (data) => if data? data = Number(data) now = new Date().getTime() ### Give the gateway some time to handle the changes. If we send new values to the cube we set _lastSendTime to the current time. We consider the values as succesfull set, when the command was not rejected. In the case that the gateway did not react to our the send commands, the values will be overwritten with the internal state (old ones) of the gateway after 30 seconds. ### if @_mode is "auto" @_setSetpoint(data) #override from gateway @_setSynced(true) ### if now - @_lastSendTime < 30*1000 # only if values match, we are synced if data is @_temperatureSetpoint @_setSynced(true) else # more then 30 seconds passed, set the values anyway @_setSetpoint(data) #override from gateway @_setSynced(true) ### return ) plugin.otgw.on("remote_override_setpoint", (data) => if data? data = Number(data) now = new Date().getTime() ### Give the gateway some time to handle the changes. If we send new values to the cube we set _lastSendTime to the current time. We consider the values as succesfull set, when the command was not rejected. In the case that the gateway did not react to our the send commands, the values will be overwritten with the internal state (old ones) of the gateway after 30 seconds. ### if @_mode is "manu" if data < 1 env.logger.debug "setting to auto" @_setMode("auto") else if now - @_lastSendTime < 30*1000 # only if values match, we are synced if data is @_temperatureSetpoint @_setSynced(true) else # more then 30 seconds passed, set the values anyway @_setSetpoint(data) @_setSynced(true) if @_mode is "auto" and data > 0.00 @_setMode("manu") return ) super() changeModeTo: (mode) -> temp = @_temperatureSetpoint if mode is "auto" temp = null return plugin.setTemperatureSetpoint(mode, temp).then( => @_lastSendTime = new Date().getTime() @_setSynced(false) @_setMode(mode) ) changeTemperatureTo: (temperatureSetpoint) -> if @temperatureSetpoint is temperatureSetpoint then return return plugin.setTemperatureSetpoint(@_mode, temperatureSetpoint).then( => @_lastSendTime = new Date().getTime() @_setSynced(false) @_setSetpoint(temperatureSetpoint) ) class OTGWMainThermostat extends env.devices.TemperatureSensor _temperature: null constructor: (@config, lastState) -> @id = @config.id @name = @config.name @_temperature = lastState?.temperature?.value super() plugin.otgw.on("room_temperature", (data) => if data? @_temperature = Number(data) @emit 'temperature', @_temperature ) getTemperature: -> Promise.resolve(@_temperature) class OTGWMainThermostat1 extends env.devices.Device temperature: null temperature1: null temperature2: null temperature3: null temperature4: null temperature5: null temperature6: null temperature7: null temperature8: null temperature9: null temperature10: null temperature11: null temperature12: null attributes: temperature: description: "Temperature" type: "number" unit: '°C' acronym: 'Control Setpoint' temperature1: description: "Temperature1" type: "number" unit: '°C' acronym: 'Remote Override Setpoint' temperature2: description: "Temperature2" type: "number" unit: '%' acronym: 'Max Relative Modulation Level' temperature3: description: "Temperature3" type: "number" unit: '°C' acronym: 'Room Setpoint' temperature4: description: "Temperature4" type: "number" unit: '%' acronym: 'Relative Modulation Level' temperature5: description: "Temperature5" type: "number" unit: 'Bar' acronym: 'Water Pressure' temperature6: description: "Temperature6" type: "number" unit: '°C' acronym: 'Room Temperature' temperature7: description: "Temperature7" type: "number" unit: '°C' acronym: 'Boiler Water Temperature' temperature8: description: "Temperature8" type: "number" unit: '°C' acronym: 'DWH Temperature' temperature9: description: "Temperature9" type: "number" unit: '°C' acronym: 'Outside Temperature' temperature10: description: "Temperature10" type: "number" unit: '°C' acronym: 'Return Water Temperature' temperature11: description: "Temperature11" type: "number" unit: '°C' acronym: 'DWH Setpoint' temperature12: description: "Temperature12" type: "number" unit: '°C' acronym: 'Max CH Water Setpoint' constructor: (@config, lastState) -> @id = @config.id @name = @config.name @temperature = lastState?.temperature?.value @temperature1 = lastState?.temperature1?.value @temperature2 = lastState?.temperature2?.value @temperature3 = lastState?.temperature3?.value @temperature4 = lastState?.temperature4?.value @temperature5 = lastState?.temperature5?.value @temperature6 = lastState?.temperature6?.value @temperature7 = lastState?.temperature7?.value @temperature8 = lastState?.temperature8?.value @temperature9 = lastState?.temperature9?.value @temperature10 = lastState?.temperature10?.value @temperature11 = lastState?.temperature11?.value @temperature12 = lastState?.temperature12?.value super() destroy: -> super() plugin.otgw.on("control_setpoint", (data) => if data? @temperature = Number(data) @emit 'temperature', @temperature ) plugin.otgw.on("remote_override_setpoint", (data) => if data? @temperature1 = Number(data) @emit 'temperature1', @temperature1 ) plugin.otgw.on("max_relative_modulation_level", (data) => if data? @temperature2 = Number(data) @emit 'temperature2', @temperature2 ) plugin.otgw.on("room_setpoint", (data) => if data? @temperature3 = Number(data) @emit 'temperature3', @temperature3 ) plugin.otgw.on("relative_modulation_level", (data) => if data? @temperature4 = Number(data) @emit 'temperature4', @temperature4 ) plugin.otgw.on("ch_water_pressure", (data) => if data? @temperature5 = Number(data) @emit 'temperature5', @temperature5 ) plugin.otgw.on("room_temperature", (data) => if data? @temperature6 = Number(data) @emit 'temperature6', @temperature6 ) plugin.otgw.on("boiler_water_temperature", (data) => if data? @temperature7 = Number(data) @emit 'temperature7', @temperature7 ) plugin.otgw.on("dhw_temperature", (data) => if data? @temperature8 = Number(data) @emit 'temperature8', @temperature8 ) plugin.otgw.on("outside_temperature", (data) => if data? @temperature9 = Number(data) @emit 'temperature9', @temperature9 ) plugin.otgw.on("return_water_temperature", (data) => if data? @temperature10 = Number(data) @emit 'temperature10', @temperature10 ) plugin.otgw.on("dhw_setpoint", (data) => if data? @temperature11 = Number(data) @emit 'temperature11', @temperature11 ) plugin.otgw.on("max_ch_water_setpoint", (data) => if data? @temperature12 = Number(data) @emit 'temperature12', @temperature12 ) getTemperature: -> Promise.resolve(@temperature) getTemperature1: -> Promise.resolve(@temperature1) getTemperature2: -> Promise.resolve(@temperature2) getTemperature3: -> Promise.resolve(@temperature3) getTemperature4: -> Promise.resolve(@temperature4) getTemperature5: -> Promise.resolve(@temperature5) getTemperature6: -> Promise.resolve(@temperature6) getTemperature7: -> Promise.resolve(@temperature7) getTemperature8: -> Promise.resolve(@temperature8) getTemperature9: -> Promise.resolve(@temperature9) getTemperature10: -> Promise.resolve(@temperature10) getTemperature11: -> Promise.resolve(@temperature11) getTemperature12: -> Promise.resolve(@temperature12) return plugin
the result in Pimatic:
Also in the Event’s i see only 0, just after restart, but no updates.
Can any body PLEASE tell me why i don’t see real values, what am i missing? -
I have the full code for all available information… send me a PM so i can send you the ZIP with code.
-
See coffee script : https://pastebin.com/Y44EgtWs
Please add the devices also to the device-config-schemaYou need to cleanup the code a little bit never had time to do so… e.g rename for the graphs.
-
@stingone Thanks for the code.
This gives me quite some good info.
Finaly I can see the boiler water temperature and control setpoint
Water presure doesn’t work in my setup yet, but I’v some options to try.I think I can change the names of the data for the graphs and I’ll try to make the class(es) configurable from the webui so the user can disable the values his boiler does not provide.
-
Good to hear never had time to rename and add option to switch off classes in the GUI. Almost no one is working on the OTGW code anymore. but please share the code with anyone.
-
@stingone said in OTGW all data to Pimatic:
Good to hear never had time to rename and add option to switch off classes in the GUI. Almost no one is working on the OTGW code anymore. but please share the code with anyone.
Nice! Will test this as well
-
Hello all readers,
I’ve managed to get what I want.
I’ve edited the otgw.coffee, device-config-schema.coffee, otgw-config-schema.coffee and node_modules/OTGW-control/index.jsIt sends out both Thermostat, Boiler as well as Request and Answer messages.
This provides me with both the Thermostat requested Control_setpoint and the Requested Control_setpoint send from the OTGW to the boiler.
The same for the Flame_status.I still don’t get how to hide the unsupported Id’s from the GUI, by config settings.
But found out that if you comment the “attributes” of the specific item it doesn’t show in the GUI / Webpage.I’ve put the files on the following pastebin links:
otgw.coffee: https://pastebin.com/s498HeWc
device-config-schema.coffee: https://pastebin.com/rtpRUeq7
otgw-config-schema.coffee: https://pastebin.com/F1Ecg2C3
index.js: https://pastebin.com/XvfjjLWqThe latest needs some work to get the Data type S8 working.
And I’m not sure the U8 type works fine because my boiler doesn’t send this data.
If you uncomment the console.log at line 250 your pimatic log will show which messages are received, so you can edit the otgw.coffee accordingly.My apologies to the NON-DUTCH for the Dutch attributes in some classes
-
@Thickness Nice Will try it soon