export of thermostat and windowcontact
This commit is contained in:
@ -27,6 +27,13 @@ export function SwitchExport(itemId: string, label: string, stateTopic: string,
|
|||||||
return { 'homekit': homekitOut, 'openhab': openhabOut }
|
return { 'homekit': homekitOut, 'openhab': openhabOut }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ThermostatExport(itemId: string, label: string, temperatureTopic: string, temperatureFeedbackTopic: string) : ExportType {
|
||||||
|
return {'homekit': ThermostatHomekitExport(itemId, label, temperatureTopic, temperatureFeedbackTopic), 'openhab': ''}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ContactExport(itemId: string, label: string, status: string) : ExportType {
|
||||||
|
return {'homekit': ContactHomekitExport(itemId, label, status), 'openhab': ''}
|
||||||
|
}
|
||||||
|
|
||||||
function SwitchHomekitBulbExport(id: string, label: string, setOn: string, statusOn: string) : HomekitExportType {
|
function SwitchHomekitBulbExport(id: string, label: string, setOn: string, statusOn: string) : HomekitExportType {
|
||||||
let o : any = {
|
let o : any = {
|
||||||
@ -67,6 +74,36 @@ function SwitchHomekitOutletExport(id: string, label: string, setOn: string, sta
|
|||||||
return { 'id': id, 'object': o }
|
return { 'id': id, 'object': o }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ThermostatHomekitExport(id: string, label: string, setTemperature: string, statusTemperature: string) : HomekitExportType {
|
||||||
|
let o : any = {
|
||||||
|
"id": id,
|
||||||
|
"name": label,
|
||||||
|
"service": "Thermostat",
|
||||||
|
"topic": {
|
||||||
|
"setTargetTemperature": setTemperature,
|
||||||
|
"statusTargetTemperature": statusTemperature,
|
||||||
|
"statusCurrentTemperature": statusTemperature
|
||||||
|
},
|
||||||
|
"payload": {}
|
||||||
|
}
|
||||||
|
return { 'id': id, 'object': o }
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContactHomekitExport(id: string, label: string, status: string) : HomekitExportType {
|
||||||
|
let o : any = {
|
||||||
|
"id": id,
|
||||||
|
"name": label,
|
||||||
|
"service": "ContactSensor",
|
||||||
|
"topic": {
|
||||||
|
"statusContactSensorState": status
|
||||||
|
},
|
||||||
|
"payload": {
|
||||||
|
"onContactDetected": "CLOSED"s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { 'id': id, 'object': o }
|
||||||
|
}
|
||||||
|
|
||||||
function SwitchOpenHABExport(id: string, label: string, setOn: string, statusOn: string): string {
|
function SwitchOpenHABExport(id: string, label: string, setOn: string, statusOn: string): string {
|
||||||
// Switch windowLightKitchen {mqtt=">[localbroker:nodered/items/windowLightKitchen:command:*:default]", mqtt="<[localbroker:nodered/items/windowLightKitchen/feedback:state:default]"}
|
// Switch windowLightKitchen {mqtt=">[localbroker:nodered/items/windowLightKitchen:command:*:default]", mqtt="<[localbroker:nodered/items/windowLightKitchen/feedback:state:default]"}
|
||||||
|
@ -3,7 +3,7 @@ import { mqttHandler } from './MqttDispatcher'
|
|||||||
import { HasInTopic } from './AItem'
|
import { HasInTopic } from './AItem'
|
||||||
import { AHomematicItem } from './AHomematicItem'
|
import { AHomematicItem } from './AHomematicItem'
|
||||||
import { MaxWindowContact } from './MaxWindowContact';
|
import { MaxWindowContact } from './MaxWindowContact';
|
||||||
// import { SwitchExport, ExportType } from './Export'
|
import { ThermostatExport, ExportType } from './Export'
|
||||||
|
|
||||||
const WINDOW_OPEN_TEMPERATURE = 4.5
|
const WINDOW_OPEN_TEMPERATURE = 4.5
|
||||||
|
|
||||||
@ -27,6 +27,10 @@ export class MaxThermostat extends AHomematicItem implements HasInTopic {
|
|||||||
return this.temperatureTopic
|
return this.temperatureTopic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportItem() : ExportType|null {
|
||||||
|
return ThermostatExport(this.itemId, this.label, this.temperatureTopic, this.temperatureFeedbackTopic)
|
||||||
|
}
|
||||||
|
|
||||||
constructor(floor: string, room: string, item: string, label: string, hmId: number, windowContacts: MaxWindowContact[]) {
|
constructor(floor: string, room: string, item: string, label: string, hmId: number, windowContacts: MaxWindowContact[]) {
|
||||||
super(floor, room, item, label, hmId)
|
super(floor, room, item, label, hmId)
|
||||||
this.temperatureTopic = `${this.topicFirstPart}/temperature`
|
this.temperatureTopic = `${this.topicFirstPart}/temperature`
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as logger from './log'
|
import * as logger from './log'
|
||||||
import { mqttHandler } from './MqttDispatcher'
|
import { mqttHandler } from './MqttDispatcher'
|
||||||
import { AHomematicItem } from './AHomematicItem'
|
import { AHomematicItem } from './AHomematicItem'
|
||||||
// import { SwitchExport, ExportType } from './Export'
|
import { ContactExport, ExportType } from './Export'
|
||||||
|
|
||||||
export class MaxWindowContact extends AHomematicItem {
|
export class MaxWindowContact extends AHomematicItem {
|
||||||
private deviceFeedbackTopic: string
|
private deviceFeedbackTopic: string
|
||||||
@ -24,6 +24,10 @@ export class MaxWindowContact extends AHomematicItem {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportItem() : ExportType|null {
|
||||||
|
return ContactExport(this.itemId, this.label, this.stateFeedbackTopic)
|
||||||
|
}
|
||||||
|
|
||||||
processMessage(topic: string, payload: string) : void {
|
processMessage(topic: string, payload: string) : void {
|
||||||
if (payload == 'true') {
|
if (payload == 'true') {
|
||||||
this.state = 'OPEN'
|
this.state = 'OPEN'
|
||||||
|
@ -197,9 +197,11 @@ allLabeledItems.push(morningLightScene)
|
|||||||
// ----------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
let windowContactBathroomGnd = new MaxWindowContact('Gnd', 'Bathroom', 'WindowContact', 'Fenster Bad unten', 7)
|
let windowContactBathroomGnd = new MaxWindowContact('Gnd', 'Bathroom', 'WindowContact', 'Fenster Bad unten', 7)
|
||||||
windowContactBathroomGnd.start()
|
windowContactBathroomGnd.start()
|
||||||
|
allLabeledItems.push(windowContactBathroomGnd)
|
||||||
|
|
||||||
let thermostatBathroomGnd = new MaxThermostat('Gnd', 'Bathroom', 'Thermostat', 'Thermostat Bad unten', 4, [windowContactBathroomGnd])
|
let thermostatBathroomGnd = new MaxThermostat('Gnd', 'Bathroom', 'Thermostat', 'Thermostat Bad unten', 4, [windowContactBathroomGnd])
|
||||||
thermostatBathroomGnd.start()
|
thermostatBathroomGnd.start()
|
||||||
|
allLabeledItems.push(thermostatBathroomGnd)
|
||||||
|
|
||||||
let thermostatBathroomGndCron = new Cron('thermostatBathroomGndCron', thermostatBathroomGnd, [
|
let thermostatBathroomGndCron = new Cron('thermostatBathroomGndCron', thermostatBathroomGnd, [
|
||||||
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
||||||
@ -213,9 +215,11 @@ thermostatBathroomGndCron.start()
|
|||||||
|
|
||||||
let windowContactBathroom1st = new MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 2)
|
let windowContactBathroom1st = new MaxWindowContact('1st', 'Bathroom', 'WindowContact', 'Fenster Bad oben', 2)
|
||||||
windowContactBathroom1st.start()
|
windowContactBathroom1st.start()
|
||||||
|
allLabeledItems.push(windowContactBathroom1st)
|
||||||
|
|
||||||
let thermostatBathroom1st = new MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st])
|
let thermostatBathroom1st = new MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st])
|
||||||
thermostatBathroom1st.start()
|
thermostatBathroom1st.start()
|
||||||
|
allLabeledItems.push(thermostatBathroom1st)
|
||||||
|
|
||||||
let thermostatBathroom1stCron = new Cron('thermostatBathroom1stCron', thermostatBathroom1st, [
|
let thermostatBathroom1stCron = new Cron('thermostatBathroom1stCron', thermostatBathroom1st, [
|
||||||
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
||||||
@ -230,16 +234,21 @@ thermostatBathroom1stCron.start()
|
|||||||
|
|
||||||
let windowContactKitchen1 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact1', 'Fenster Küche Garten', 11)
|
let windowContactKitchen1 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact1', 'Fenster Küche Garten', 11)
|
||||||
windowContactKitchen1.start()
|
windowContactKitchen1.start()
|
||||||
|
allLabeledItems.push(windowContactKitchen1)
|
||||||
let windowContactKitchen2 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact2', 'Fenster Küche Terassentür Garten', 10)
|
let windowContactKitchen2 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact2', 'Fenster Küche Terassentür Garten', 10)
|
||||||
windowContactKitchen2.start()
|
windowContactKitchen2.start()
|
||||||
|
allLabeledItems.push(windowContactKitchen2)
|
||||||
let windowContactKitchen3 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact3', 'Fenster Küche Straße 1', 12)
|
let windowContactKitchen3 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact3', 'Fenster Küche Straße 1', 12)
|
||||||
windowContactKitchen3.start()
|
windowContactKitchen3.start()
|
||||||
|
allLabeledItems.push(windowContactKitchen3)
|
||||||
let windowContactKitchen4 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact4', 'Fenster Küche Straße 2', 13)
|
let windowContactKitchen4 = new MaxWindowContact('Gnd', 'Kitchen', 'WindowContact4', 'Fenster Küche Straße 2', 13)
|
||||||
windowContactKitchen4.start()
|
windowContactKitchen4.start()
|
||||||
|
allLabeledItems.push(windowContactKitchen4)
|
||||||
|
|
||||||
let thermostatKitchen = new MaxThermostat('Gnd', 'Kitchen', 'Thermostat', 'Thermostat Küche', 14, [
|
let thermostatKitchen = new MaxThermostat('Gnd', 'Kitchen', 'Thermostat', 'Thermostat Küche', 14, [
|
||||||
windowContactKitchen1, windowContactKitchen2, windowContactKitchen3, windowContactKitchen4])
|
windowContactKitchen1, windowContactKitchen2, windowContactKitchen3, windowContactKitchen4])
|
||||||
thermostatKitchen.start()
|
thermostatKitchen.start()
|
||||||
|
allLabeledItems.push(thermostatKitchen)
|
||||||
|
|
||||||
let thermostatKitchenCron = new Cron('thermostatKitchenCron', thermostatKitchen, [
|
let thermostatKitchenCron = new Cron('thermostatKitchenCron', thermostatKitchen, [
|
||||||
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
{cronTime: '00 00 06 * * 1-5', output: '21.0'},
|
||||||
|
Reference in New Issue
Block a user