Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for milight white bulbs #43

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions device-config-schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ module.exports = {
description: "Zone [0 - 4], 0 = switches all zones"
type: "number"
},
MilightCWWW: {
title: "Milight"
type: "object"
properties:
addr:
description: "IP-Address of light device"
type: "string"
zone:
description: "Zone [0 - 4], 0 = switches all zones"
type: "number"
},
MilightRF24: {
title: "Milight"
type: "object"
Expand Down
44 changes: 44 additions & 0 deletions devices/milightCWWW.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = (env) ->
Promise = env.require 'bluebird'
_ = require 'lodash'
Color = require 'color'
nodeMilight = require 'node-milight-promise'
BaseLedLight = require('./base')(env)


class MilightCWWW extends BaseLedLight

constructor: (@config, lastState) ->
@device = new nodeMilight.MilightController
ip: @config.addr
delayBetweenCommands: 50
commandRepeat: 2

@zone = @config.zone

initState = _.clone lastState
for key, value of lastState
initState[key] = value.value
super(initState)
if @power then @turnOn() else @turnOff()

_updateState: (attr) ->
state = _.assign @getState(), attr
super null, state

turnOn: ->
@_updateState power: true

@device.sendCommands(nodeMilight.commands.white.on(@zone))
@device.sendCommands(nodeMilight.commands.white.maxBright())

Promise.resolve()

turnOff: ->
@_updateState power: false

@device.sendCommands(nodeMilight.commands.white.off(@zone))

Promise.resolve()

return MilightCWWW
5 changes: 5 additions & 0 deletions pimatic-led-light.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = (env) ->
# import device wrappers
IwyMaster = require('./devices/iwy_master')(env)
Milight = require('./devices/milight')(env)
MilightCWWW = require('./devices/milightCWWW')(env)
MilightRF24 = require('./devices/milightRF24')(env)
Wifi370 = require('./devices/wifi370')(env)
unless process.env.NODE_ENV is 'travis-test'
Expand Down Expand Up @@ -30,6 +31,10 @@ module.exports = (env) ->
configDef: deviceConfigDef.Milight
createCallback: (config, lastState) -> return new Milight(config, lastState)

@framework.deviceManager.registerDeviceClass 'MilightCWWW',
configDef: deviceConfigDef.MilightCWWW
createCallback: (config, lastState) -> return new MilightCWWW(config, lastState)

@framework.deviceManager.registerDeviceClass 'MilightRF24',
configDef: deviceConfigDef.MilightRF24
createCallback: (config, lastState) ->
Expand Down