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

14
dist/AHomegearItem.js vendored Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AItem_1 = require("./AItem");
class AHomegearItem extends AItem_1.AItem {
constructor(floor, room, item, label, hmId) {
super(floor, room, item, label);
this.hmId = hmId;
this.homegearTopicPre = 'homegear/instance1';
this.actionTopicPre = `${this.homegearTopicPre}/set/${this.hmId}`;
this.deviceTopicPre = `${this.homegearTopicPre}/plain/${this.hmId}`;
}
}
exports.AHomegearItem = AHomegearItem;
//# sourceMappingURL=AHomegearItem.js.map

View File

@ -2,8 +2,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
class HomematicDimmerItem extends AHomematicItem_1.AHomematicItem {
const AHomegearItem_1 = require("./AHomegearItem");
class HomematicDimmerItem extends AHomegearItem_1.AHomegearItem {
constructor(floor, room, item, label, hmId) {
super(floor, room, item, label, hmId);
this.stateTopic = `${this.topicFirstPart}/state`;

View File

@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
const AHomegearItem_1 = require("./AHomegearItem");
class HomematicFourButtonSingleItem {
constructor(actionTopic) {
this.actionTopic = actionTopic;
@ -26,7 +26,7 @@ class HomematicFourButtonSingleItem {
}
}
exports.HomematicFourButtonSingleItem = HomematicFourButtonSingleItem;
class HomematicFourButtonThing extends AHomematicItem_1.AHomematicItem {
class HomematicFourButtonThing extends AHomegearItem_1.AHomegearItem {
constructor(floor, room, item, hmId, itemObjs) {
super(floor, room, item, '', hmId);
this.itemObjs = itemObjs;

View File

@ -1,9 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
const AHomegearItem_1 = require("./AHomegearItem");
const Export_1 = require("./Export");
class HomematicSwitchItem extends AHomematicItem_1.AHomematicItem {
class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
getStateTopic() {
return this.stateTopic;
}

52
dist/HueColorTemperatureBulbItem.js vendored Normal file
View File

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomegearItem_1 = require("./AHomegearItem");
class HueColorTemperatureBulbItem extends AHomegearItem_1.AHomegearItem {
constructor(floor, room, item, label, hmId) {
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, payload) {
switch (topic) {
case this.stateTopic:
this.state = payload;
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
if (this.state == "ON") {
MqttDispatcher_1.mqttHandler.send(this.stateActionTopic, "true");
}
else {
MqttDispatcher_1.mqttHandler.send(this.stateActionTopic, "false");
}
break;
case this.brightTopic:
this.bright = parseInt(payload);
MqttDispatcher_1.mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`);
MqttDispatcher_1.mqttHandler.send(this.brightActionTopic, `${this.bright}`);
break;
case this.colorTemperatureTopic:
this.colorTemperature = parseInt(payload);
MqttDispatcher_1.mqttHandler.send(this.colorTemperatureFeedbackTopic, `${this.colorTemperature}`);
MqttDispatcher_1.mqttHandler.send(this.colorTemperatureActionTopic, `${this.colorTemperature}`);
break;
}
}
}
exports.HueColorTemperatureBulbItem = HueColorTemperatureBulbItem;
//# sourceMappingURL=HueColorTemperatureBulbItem.js.map

View File

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
class MaxEcoSwitch extends AHomematicItem_1.AHomematicItem {
const AHomegearItem_1 = require("./AHomegearItem");
class MaxEcoSwitch extends AHomegearItem_1.AHomegearItem {
constructor(floor, room, item, label, hmId, mainScene, ecoScene) {
super(floor, room, item, label, hmId);
this.mainButtonTopic = `${this.deviceTopicPre}/1/PRESS`;

View File

@ -1,10 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
const AHomegearItem_1 = require("./AHomegearItem");
const Export_1 = require("./Export");
const WINDOW_OPEN_TEMPERATURE = 4.5;
class MaxThermostat extends AHomematicItem_1.AHomematicItem {
class MaxThermostat extends AHomegearItem_1.AHomegearItem {
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
getInTopic() {
return this.temperatureTopic;

View File

@ -1,9 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomematicItem_1 = require("./AHomematicItem");
const AHomegearItem_1 = require("./AHomegearItem");
const Export_1 = require("./Export");
class MaxWindowContact extends AHomematicItem_1.AHomematicItem {
class MaxWindowContact extends AHomegearItem_1.AHomegearItem {
getStateFeedbackTopic() {
return this.stateFeedbackTopic;
}

3
dist/main.js vendored
View File

@ -17,6 +17,7 @@ const MaxThermostat_1 = require("./MaxThermostat");
const MaxWindowContact_1 = require("./MaxWindowContact");
const UrlSwitchItem_1 = require("./UrlSwitchItem");
const Cron_1 = require("./Cron");
const HueColorTemperatureBulbItem_1 = require("./HueColorTemperatureBulbItem");
logger.info("Dispatcher starting");
let allLabeledItems = new Array();
// Anna -----------------------------------------------------------------------------------------------------
@ -66,6 +67,8 @@ allLabeledItems.push(diningRoomCupboardLight);
let diningRoomShelfLight = new UrlSwitchItem_1.UrlSwitchItem('Gnd', 'DiningRoom', 'ShelfLight', 'Regallicht Esszimmer', 'http://regallampe/dv?dv=1023', 'http://regallampe/dv?dv=0');
diningRoomShelfLight.start();
allLabeledItems.push(diningRoomShelfLight);
let diningRoomNaehkaestchenLight = new HueColorTemperatureBulbItem_1.HueColorTemperatureBulbItem('Gnd', 'DiningRoom', 'NaehkaestchenLight', 'Lampe Naehkaestchen', 15);
diningRoomNaehkaestchenLight.start();
// Wohnzimmer -----------------------------------------------------------------------------------------------
// Wohnzimmer grosse Lampe 65557 24 1 65556 24 1
let livingRoomLargeLight = new M433SwitchItem_1.M433SwitchItem('Gnd', 'LivingRoom', 'LargeLight', 'große Lampe Wohnzimmer', '65557 24 1', '65556 24 1');

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')