You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
592 B
28 lines
592 B
var light = (client, clientId) => { |
|
|
|
var o = { |
|
state: false, |
|
LastOnTime: new Date().valueOf(), |
|
LastOffTime: new Date().valueOf(), |
|
on: ()=>{ |
|
client.publish('hass/autoLight/'+clientId, '1'); |
|
}, |
|
off: ()=>{ |
|
client.publish('hass/autoLight/'+clientId, '0'); |
|
} |
|
|
|
}; |
|
|
|
|
|
client.on('message', (subject, msg)=>{ |
|
if(subject == 'hass/snsr/'+clientId+'/lightCtl'){ |
|
if(msg == 1) o.state = true; |
|
if(msg == 0) o.state = false; |
|
} |
|
}); |
|
|
|
return o; |
|
} |
|
|
|
|
|
exports.light = light;
|
|
|