I control the inverter with a few restrictions, here is part of my code which is run every X seconds:
var inbound = msg.payload;
var upper = 90.0;
var lower = upper - 3;
if(inbound === true){
var switchState = flow.get("switchState") || 0; //get switch state from this flow, if value is empty...