Ability to change duration of K's activity timer when running
tm24fan8/Home-Assistant-Configs#153
This commit is contained in:
20
kallen-timer/timer-change.js
Normal file
20
kallen-timer/timer-change.js
Normal file
@ -0,0 +1,20 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const oldState = msg.data.old_state.state
|
||||
const newState = msg.data.new_state.state
|
||||
const entity_id = msg.data.entity_id
|
||||
const subtract = newState - oldState
|
||||
const multiply = subtract * 60
|
||||
const diff = parseInt(multiply)
|
||||
const running = states["timer.kallen_timer"].state
|
||||
|
||||
let changeMsg = {
|
||||
"timer": "timer.kallen_timer",
|
||||
"change": diff
|
||||
}
|
||||
|
||||
if (running === 'active') {
|
||||
node.send(changeMsg)
|
||||
node.status({fill:"green",shape:"dot",text:"Timer Changed"})
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Blocked"})
|
||||
}
|
Reference in New Issue
Block a user