Auto shower mode
This commit is contained in:
25
second-floor-lighting/upstairs-bathroom/auto-shower-mode.js
Normal file
25
second-floor-lighting/upstairs-bathroom/auto-shower-mode.js
Normal file
@ -0,0 +1,25 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const showerMode = states['input_boolean.shower_mode'].state
|
||||
const tempChange = parseFloat(msg.payload)
|
||||
|
||||
let action = {}
|
||||
|
||||
if (tempChange < 0) {
|
||||
action = 'off'
|
||||
} else if (tempChange >= 5.0) {
|
||||
action = 'on'
|
||||
} else {
|
||||
action = 'none'
|
||||
}
|
||||
|
||||
let actionMsg = {
|
||||
'action': 'turn_' + action
|
||||
}
|
||||
|
||||
if ((action === 'on' && showerMode === 'off') || (action === 'off' && showerMode === 'on')) {
|
||||
node.status({fill:'green',shape:'dot',text:'Shower Mode ' + action})
|
||||
node.send(actionMsg)
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'No action taken'})
|
||||
return null
|
||||
}
|
Reference in New Issue
Block a user