first Hue light

This commit is contained in:
Wolfgang Hottgenroth
2018-01-25 16:23:06 +01:00
parent 32a57408d9
commit 11c3def220
18 changed files with 162 additions and 25 deletions

View File

@ -1,7 +1,7 @@
import { AItem } from './AItem'
export abstract class AHomematicItem extends AItem {
export abstract class AHomegearItem extends AItem {
protected deviceTopicPre: string;
protected actionTopicPre: string;
protected homegearTopicPre: string;

View File

@ -1,9 +1,9 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
export class HomematicDimmerItem extends AHomematicItem {
export class HomematicDimmerItem extends AHomegearItem {
private oldBright: number|undefined
private bright: number
private oldState: string|undefined

View File

@ -1,6 +1,6 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
export class HomematicFourButtonSingleItem {
@ -29,7 +29,7 @@ export class HomematicFourButtonSingleItem {
}
}
export class HomematicFourButtonThing extends AHomematicItem {
export class HomematicFourButtonThing extends AHomegearItem {
private itemObjs: HomematicFourButtonSingleItem[]
constructor(floor: string, room: string, item: string, hmId: number, itemObjs: HomematicFourButtonSingleItem[]) {

View File

@ -1,10 +1,10 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
import { SwitchExport, ExportType } from './Export'
import { HasStateAndFeedbackTopic } from './AItem';
export class HomematicSwitchItem extends AHomematicItem implements HasStateAndFeedbackTopic {
export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFeedbackTopic {
private oldState: string|undefined
private state: string
private actionTopic: string

View File

@ -0,0 +1,64 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomegearItem } from './AHomegearItem'
export class HueColorTemperatureBulbItem extends AHomegearItem {
private bright: number
private colorTemperature: number
private state: string
private stateActionTopic: string
private brightActionTopic: string
private colorTemperatureActionTopic: string
private brightFeedbackTopic: string
private stateFeedbackTopic: string
private colorTemperatureFeedbackTopic: string
private brightTopic: string
private stateTopic: string
private colorTemperatureTopic: string
constructor(floor: string, room: string, item: string, label: string, hmId: number) {
super(floor, room, item, label, hmId)
this.stateTopic = `${this.topicFirstPart}/state`
this.brightTopic = `${this.topicFirstPart}/bright`
this.colorTemperatureTopic = `${this.topicFirstPart}/colorTemperature`
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`
this.colorTemperatureFeedbackTopic = `${this.topicFirstPart}/colorTemperature/feedback`
this.stateActionTopic = `${this.actionTopicPre}/1/STATE`
this.brightActionTopic = `${this.actionTopicPre}/1/BRIGHTNESS`
this.colorTemperatureActionTopic = `${this.actionTopicPre}/1/COLOR_TEMPERATURE`
this.subscribeTopics = [
this.stateTopic,
this.brightTopic,
this.colorTemperatureTopic
]
this.state = 'OFF'
this.bright = 0
this.colorTemperature = 0
}
processMessage(topic: string, payload: string) : void {
switch (topic) {
case this.stateTopic:
this.state = payload
mqttHandler.send(this.stateFeedbackTopic, this.state)
if (this.state == "ON") {
mqttHandler.send(this.stateActionTopic, "true")
} else {
mqttHandler.send(this.stateActionTopic, "false")
}
break
case this.brightTopic:
this.bright = parseInt(payload)
mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`)
mqttHandler.send(this.brightActionTopic, `${this.bright}`)
break
case this.colorTemperatureTopic:
this.colorTemperature = parseInt(payload)
mqttHandler.send(this.colorTemperatureFeedbackTopic, `${this.colorTemperature}`)
mqttHandler.send(this.colorTemperatureActionTopic, `${this.colorTemperature}`)
break
}
}
}

View File

@ -1,9 +1,9 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
import { LightScene } from './Scene'
export class MaxEcoSwitch extends AHomematicItem {
export class MaxEcoSwitch extends AHomegearItem {
private ecoTopic: string
private mainTopic: string
private mainButtonTopic: string

View File

@ -1,7 +1,7 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { HasInTopic } from './AItem'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
import { MaxWindowContact } from './MaxWindowContact';
import { ThermostatExport, ExportType } from './Export'
@ -13,7 +13,7 @@ type WindowContactHolder = {
state : string
}
export class MaxThermostat extends AHomematicItem implements HasInTopic {
export class MaxThermostat extends AHomegearItem implements HasInTopic {
private actionTopic: string
private deviceFeedbackTopic: string
private temperatureFeedbackTopic: string

View File

@ -1,9 +1,9 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { AHomegearItem } from './AHomegearItem'
import { ContactExport, ExportType } from './Export'
export class MaxWindowContact extends AHomematicItem {
export class MaxWindowContact extends AHomegearItem {
private deviceFeedbackTopic: string
private stateFeedbackTopic: string
private stateTopic: string

View File

@ -19,6 +19,7 @@ import { MaxThermostat } from './MaxThermostat'
import { MaxWindowContact } from './MaxWindowContact'
import { UrlSwitchItem } from './UrlSwitchItem'
import { Cron } from './Cron'
import { HueColorTemperatureBulbItem } from './HueColorTemperatureBulbItem'
logger.info("Dispatcher starting")
@ -83,6 +84,9 @@ let diningRoomShelfLight = new UrlSwitchItem('Gnd', 'DiningRoom', 'ShelfLight',
diningRoomShelfLight.start()
allLabeledItems.push(diningRoomShelfLight)
let diningRoomNaehkaestchenLight = new HueColorTemperatureBulbItem('Gnd', 'DiningRoom', 'NaehkaestchenLight', 'Lampe Naehkaestchen', 15)
diningRoomNaehkaestchenLight.start()
// Wohnzimmer -----------------------------------------------------------------------------------------------
// Wohnzimmer grosse Lampe 65557 24 1 65556 24 1
let livingRoomLargeLight = new M433SwitchItem('Gnd', 'LivingRoom', 'LargeLight', 'große Lampe Wohnzimmer', '65557 24 1', '65556 24 1')