Ability to change duration of K's activity timer when running

tm24fan8/Home-Assistant-Configs#153
This commit is contained in:
2023-10-02 16:17:58 -04:00
parent 900647d12a
commit 37466a4526

View 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"})
}