hue light
This commit is contained in:
@ -35,6 +35,16 @@ export function ContactExport(itemId: string, label: string, status: string) : E
|
|||||||
return {'homekit': ContactHomekitExport(itemId, label, status), 'openhab': ''}
|
return {'homekit': ContactHomekitExport(itemId, label, status), 'openhab': ''}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function HueColorLightExport(itemId: string, label: string,
|
||||||
|
stateTopic: string, stateFeedbackTopic: string,
|
||||||
|
brightnessTopic: string, brightnessFeedbackTopic: string,
|
||||||
|
hueTopic: string, hueFeedbackTopic: string,
|
||||||
|
saturationTopic: string, saturationFeedbackTopic: string,
|
||||||
|
colorTemperatureTopic: string, colorTemperatureFeedbackTopic: string) {
|
||||||
|
return {'homekit': HueColorLightHomekitExport(itemId, label, stateTopic, stateFeedbackTopic,
|
||||||
|
brightnessTopic, brightnessFeedbackTopic, hueTopic, hueFeedbackTopic,
|
||||||
|
saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic), '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 = {
|
||||||
"id": id,
|
"id": id,
|
||||||
@ -109,3 +119,38 @@ function SwitchOpenHABExport(id: string, label: string, setOn: string, statusOn:
|
|||||||
// 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]"}
|
||||||
return `Switch ${id} {mqtt=">[localbroker:${setOn}:command:*:default],<[localbroker:${statusOn}:state:default]"}`
|
return `Switch ${id} {mqtt=">[localbroker:${setOn}:command:*:default],<[localbroker:${statusOn}:state:default]"}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function HueColorLightHomekitExport(id: string, label: string,
|
||||||
|
stateTopic: string, stateFeedbackTopic: string,
|
||||||
|
brightnessTopic: string, brightnessFeedbackTopic: string,
|
||||||
|
hueTopic: string, hueFeedbackTopic: string,
|
||||||
|
saturationTopic: string, saturationFeedbackTopic: string,
|
||||||
|
colorTemperatureTopic: string, colorTemperatureFeedbackTopic: string) {
|
||||||
|
let o: any = {
|
||||||
|
"id": id,
|
||||||
|
"name": label,
|
||||||
|
"service": "Lightbulb",
|
||||||
|
"manufacturer": "hue2mqtt - Hue",
|
||||||
|
"model": "color light",
|
||||||
|
"topic": {
|
||||||
|
"setOn": stateTopic,
|
||||||
|
"statusOn": stateFeedbackTopic,
|
||||||
|
"setBrightness": brightnessTopic,
|
||||||
|
"statusBrightness": brightnessFeedbackTopic,
|
||||||
|
"setHue": hueTopic,
|
||||||
|
"statusHue": hueFeedbackTopic,
|
||||||
|
"setSaturation": saturationTopic,
|
||||||
|
"statusSaturation": saturationFeedbackTopic,
|
||||||
|
"setColorTemperature": colorTemperatureTopic,
|
||||||
|
"statusColorTemperature": colorTemperatureFeedbackTopic
|
||||||
|
},
|
||||||
|
"payload": {
|
||||||
|
"onTrue": "ON",
|
||||||
|
"onFalse": "OFF",
|
||||||
|
"brightnessFactor": 1,
|
||||||
|
"hueFactor": 1,
|
||||||
|
"saturationFactor": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { 'id': id, 'object': o}
|
||||||
|
}
|
@ -1,19 +1,28 @@
|
|||||||
import * as logger from './log'
|
import * as logger from './log'
|
||||||
import { mqttHandler } from './MqttDispatcher'
|
import { mqttHandler } from './MqttDispatcher'
|
||||||
import { AHomegearItem } from './AHomegearItem'
|
import { AHomegearItem } from './AHomegearItem'
|
||||||
|
import { HueColorLightExport, ExportType } from './Export'
|
||||||
|
|
||||||
export class HueColorTemperatureBulbItem extends AHomegearItem {
|
export class HueColorBulbItem extends AHomegearItem {
|
||||||
private bright: number
|
private bright: number
|
||||||
private colorTemperature: number
|
private colorTemperature: number
|
||||||
|
private hue: number
|
||||||
|
private saturation: number
|
||||||
private state: string
|
private state: string
|
||||||
private stateActionTopic: string
|
private stateActionTopic: string
|
||||||
private brightActionTopic: string
|
private brightActionTopic: string
|
||||||
private colorTemperatureActionTopic: string
|
private colorTemperatureActionTopic: string
|
||||||
|
private hueActionTopic: string
|
||||||
|
private saturationActionTopic: string
|
||||||
private brightFeedbackTopic: string
|
private brightFeedbackTopic: string
|
||||||
private stateFeedbackTopic: string
|
private stateFeedbackTopic: string
|
||||||
private colorTemperatureFeedbackTopic: string
|
private colorTemperatureFeedbackTopic: string
|
||||||
|
private hueFeedbackTopic: string
|
||||||
|
private saturationFeedbackTopic: string
|
||||||
private brightTopic: string
|
private brightTopic: string
|
||||||
private stateTopic: string
|
private stateTopic: string
|
||||||
|
private hueTopic: string
|
||||||
|
private saturationTopic: string
|
||||||
private colorTemperatureTopic: string
|
private colorTemperatureTopic: string
|
||||||
|
|
||||||
constructor(floor: string, room: string, item: string, label: string, hmId: number) {
|
constructor(floor: string, room: string, item: string, label: string, hmId: number) {
|
||||||
@ -21,20 +30,39 @@ export class HueColorTemperatureBulbItem extends AHomegearItem {
|
|||||||
this.stateTopic = `${this.topicFirstPart}/state`
|
this.stateTopic = `${this.topicFirstPart}/state`
|
||||||
this.brightTopic = `${this.topicFirstPart}/bright`
|
this.brightTopic = `${this.topicFirstPart}/bright`
|
||||||
this.colorTemperatureTopic = `${this.topicFirstPart}/colorTemperature`
|
this.colorTemperatureTopic = `${this.topicFirstPart}/colorTemperature`
|
||||||
|
this.hueTopic = `${this.topicFirstPart}/hue`
|
||||||
|
this.saturationTopic = `${this.topicFirstPart}/saturation`
|
||||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
||||||
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`
|
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`
|
||||||
|
this.hueFeedbackTopic = `${this.topicFirstPart}/bright/hue`
|
||||||
|
this.saturationFeedbackTopic = `${this.topicFirstPart}/bright/saturation`
|
||||||
this.colorTemperatureFeedbackTopic = `${this.topicFirstPart}/colorTemperature/feedback`
|
this.colorTemperatureFeedbackTopic = `${this.topicFirstPart}/colorTemperature/feedback`
|
||||||
this.stateActionTopic = `${this.actionTopicPre}/1/STATE`
|
this.stateActionTopic = `${this.actionTopicPre}/1/STATE`
|
||||||
this.brightActionTopic = `${this.actionTopicPre}/1/BRIGHTNESS`
|
this.brightActionTopic = `${this.actionTopicPre}/1/BRIGHTNESS`
|
||||||
|
this.hueActionTopic = `${this.actionTopicPre}/1/HUE`
|
||||||
|
this.saturationActionTopic = `${this.actionTopicPre}/1/SATURATION`
|
||||||
this.colorTemperatureActionTopic = `${this.actionTopicPre}/1/COLOR_TEMPERATURE`
|
this.colorTemperatureActionTopic = `${this.actionTopicPre}/1/COLOR_TEMPERATURE`
|
||||||
this.subscribeTopics = [
|
this.subscribeTopics = [
|
||||||
this.stateTopic,
|
this.stateTopic,
|
||||||
this.brightTopic,
|
this.brightTopic,
|
||||||
this.colorTemperatureTopic
|
this.colorTemperatureTopic,
|
||||||
|
this.hueTopic,
|
||||||
|
this.saturationTopic
|
||||||
]
|
]
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
this.bright = 0
|
this.bright = 0
|
||||||
this.colorTemperature = 0
|
this.colorTemperature = 0
|
||||||
|
this.hue = 0
|
||||||
|
this.saturation = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
exportItem() : ExportType|null {
|
||||||
|
return HueColorLightExport(this.itemId, this.label,
|
||||||
|
this.stateTopic, this.stateFeedbackTopic,
|
||||||
|
this.brightTopic, this.brightFeedbackTopic,
|
||||||
|
this.hueTopic, this.hueFeedbackTopic,
|
||||||
|
this.saturationTopic, this.saturationFeedbackTopic,
|
||||||
|
this.colorTemperatureTopic, this.colorTemperatureFeedbackTopic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,9 +78,19 @@ export class HueColorTemperatureBulbItem extends AHomegearItem {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case this.brightTopic:
|
case this.brightTopic:
|
||||||
this.bright = parseInt(payload)
|
this.bright = parseFloat(payload)
|
||||||
mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`)
|
mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`)
|
||||||
mqttHandler.send(this.brightActionTopic, `${this.bright}`)
|
mqttHandler.send(this.brightActionTopic, `${this.bright} * 2.54`)
|
||||||
|
break
|
||||||
|
case this.hueTopic:
|
||||||
|
this.hue = parseFloat(payload)
|
||||||
|
mqttHandler.send(this.hueFeedbackTopic, `${this.hue}`)
|
||||||
|
mqttHandler.send(this.hueActionTopic, `${this.hue} * 65535.0 / 360.0`)
|
||||||
|
break
|
||||||
|
case this.saturationTopic:
|
||||||
|
this.saturation = parseFloat(payload)
|
||||||
|
mqttHandler.send(this.saturationFeedbackTopic, `${this.saturation}`)
|
||||||
|
mqttHandler.send(this.saturationActionTopic, `${this.saturation} * 2.54`)
|
||||||
break
|
break
|
||||||
case this.colorTemperatureTopic:
|
case this.colorTemperatureTopic:
|
||||||
this.colorTemperature = parseInt(payload)
|
this.colorTemperature = parseInt(payload)
|
@ -19,7 +19,7 @@ import { MaxThermostat } from './MaxThermostat'
|
|||||||
import { MaxWindowContact } from './MaxWindowContact'
|
import { MaxWindowContact } from './MaxWindowContact'
|
||||||
import { UrlSwitchItem } from './UrlSwitchItem'
|
import { UrlSwitchItem } from './UrlSwitchItem'
|
||||||
import { Cron } from './Cron'
|
import { Cron } from './Cron'
|
||||||
import { HueColorTemperatureBulbItem } from './HueColorTemperatureBulbItem'
|
import { HueColorBulbItem } from './HueColorBulbItem'
|
||||||
|
|
||||||
logger.info("Dispatcher starting")
|
logger.info("Dispatcher starting")
|
||||||
|
|
||||||
@ -84,8 +84,9 @@ let diningRoomShelfLight = new UrlSwitchItem('Gnd', 'DiningRoom', 'ShelfLight',
|
|||||||
diningRoomShelfLight.start()
|
diningRoomShelfLight.start()
|
||||||
allLabeledItems.push(diningRoomShelfLight)
|
allLabeledItems.push(diningRoomShelfLight)
|
||||||
|
|
||||||
let diningRoomNaehkaestchenLight = new HueColorTemperatureBulbItem('Gnd', 'DiningRoom', 'NaehkaestchenLight', 'Lampe Naehkaestchen', 15)
|
let diningRoomNaehkaestchenLight = new HueColorBulbItem('Gnd', 'DiningRoom', 'NaehkaestchenLight', 'Lampe Naehkaestchen', 15)
|
||||||
diningRoomNaehkaestchenLight.start()
|
diningRoomNaehkaestchenLight.start()
|
||||||
|
allLabeledItems.push(diningRoomNaehkaestchenLight)
|
||||||
|
|
||||||
// Wohnzimmer -----------------------------------------------------------------------------------------------
|
// Wohnzimmer -----------------------------------------------------------------------------------------------
|
||||||
// Wohnzimmer grosse Lampe 65557 24 1 65556 24 1
|
// Wohnzimmer grosse Lampe 65557 24 1 65556 24 1
|
||||||
@ -144,6 +145,10 @@ let bedRoomWolfgangsSide = new M433SwitchItem('1st', 'BedRoom', 'WolfgangsSide',
|
|||||||
bedRoomWolfgangsSide.start()
|
bedRoomWolfgangsSide.start()
|
||||||
allLabeledItems.push(bedRoomWolfgangsSide)
|
allLabeledItems.push(bedRoomWolfgangsSide)
|
||||||
|
|
||||||
|
let bedRoomWolfgangBedLight = new HueColorBulbItem('1st', 'BedRoom', 'WolfgangBedLight', 'Bettlicht', 15)
|
||||||
|
bedRoomWolfgangBedLight.start()
|
||||||
|
allLabeledItems.push(bedRoomWolfgangBedLight)
|
||||||
|
|
||||||
// Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1
|
// Schlafzimmer Pattys Seite 13980756 24 1 13980753 24 1
|
||||||
let bedRoomPattysSide = new M433SwitchItem('1st', 'BedRoom', 'PattysSide', 'Pattys Seite Schlafzimmer', '13980756 24 1', '13980753 24 1')
|
let bedRoomPattysSide = new M433SwitchItem('1st', 'BedRoom', 'PattysSide', 'Pattys Seite Schlafzimmer', '13980756 24 1', '13980753 24 1')
|
||||||
bedRoomPattysSide.start()
|
bedRoomPattysSide.start()
|
||||||
|
Reference in New Issue
Block a user