diff --git a/kallen-timer/timer-change.js b/kallen-timer/timer-change.js new file mode 100644 index 0000000..49f183e --- /dev/null +++ b/kallen-timer/timer-change.js @@ -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"}) +} \ No newline at end of file