Compare commits
4 Commits
lightingfx
...
2025.3.0
Author | SHA1 | Date | |
---|---|---|---|
b628a0b197
|
|||
0f6b6a8275
|
|||
e23c78c971
|
|||
87ed0e89c0
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
|||||||
/.vscode
|
**.vscode
|
@ -13,7 +13,7 @@ if (outsideTemp > 32) {
|
|||||||
if (nightMode === 'on') {
|
if (nightMode === 'on') {
|
||||||
preset = "frost"
|
preset = "frost"
|
||||||
} else {
|
} else {
|
||||||
preset = "eco"
|
preset = "activity"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,17 +7,22 @@ const payload = msg.payload
|
|||||||
const newDuration = duration * 60
|
const newDuration = duration * 60
|
||||||
|
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold || lights === 'on') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
|
} else {
|
||||||
|
if (lights === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (payload === 'off') {
|
} else if (payload === 'off') {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const states = global.get('homeassistant.homeAssistant.states')
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
const lights = states['light.mud_room_overhead'].state
|
const lights = states['light.mud_room_overhead'].state
|
||||||
|
const selScene = states['input_text.mud_room_selected_scene'].state
|
||||||
const duration = states['input_number.mud_room_lights_off_delay'].state
|
const duration = states['input_number.mud_room_lights_off_delay'].state
|
||||||
const lux = parseInt(states['sensor.mud_room_illuminance'].state)
|
const lux = parseInt(states['sensor.mud_room_illuminance'].state)
|
||||||
const threshold = parseInt(states['input_number.mud_room_lux_threshold'].state)
|
const threshold = parseInt(states['input_number.mud_room_lux_threshold'].state)
|
||||||
@ -7,17 +8,22 @@ const payload = msg.payload
|
|||||||
const newDuration = duration * 60
|
const newDuration = duration * 60
|
||||||
|
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold || lights === 'on') {
|
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
|
||||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
|
} else {
|
||||||
|
if (lights === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (payload === 'off') {
|
} else if (payload === 'off') {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,22 @@ const newDuration = duration * 60
|
|||||||
|
|
||||||
if (sleeping === 'off') {
|
if (sleeping === 'off') {
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold || lights === 'on') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
|
} else {
|
||||||
|
if (lights === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (payload === 'off') {
|
} else if (payload === 'off') {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,22 @@ const newDuration = duration * 60
|
|||||||
|
|
||||||
if (sleeping === 'off') {
|
if (sleeping === 'off') {
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold || lights === 'on') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
|
} else {
|
||||||
|
if (lights === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (payload === 'off') {
|
} else if (payload === 'off') {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,22 @@ const newDuration = duration * 60
|
|||||||
|
|
||||||
if (peopleSleeping === false && nightMode === 'off') {
|
if (peopleSleeping === false && nightMode === 'off') {
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold || lights === 'on') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
|
} else {
|
||||||
|
if (lights === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (payload === 'off') {
|
} else if (payload === 'off') {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user