A simple dimmer toggle

This code queries the level of a dimmer(engine.query()[1].get(“LEVEL”)), regardless of the Event that has triggered the Macro, and turns it ON (engine.fire()) on full intensity if it was OFF, or turns it OFF if it was ON. It also prints notice of the action it takes in the Log (Debug()).

function(event, engine) 
    local result = engine.query("global/main/DIMMER/New DIMMER")
    if result[1].get("LEVEL") == "0" then
   Debug("Turning on global/main/DIMMER/New DIMMER")
       engine.fire("global/main/DIMMER/New DIMMER/SET?LEVEL=100");
    else
   Debug("Turning off global/main/DIMMER/New DIMMER")
       engine.fire("global/main/DIMMER/New DIMMER/SET?LEVEL=0");
    end
end