return {
    -- The script is active
    active = true,

    -- Trigger section: when the device changes
    on = {
        devices = {
            'Bathroom fan'     -- Replace with the name of the device
        }
    },

    -- Custom logging level for this script
    logging = {
        level = domoticz.LOG_INFO,
        marker = "AWTRIX_Bathroom_Fan"
    },

    -- Event execution when the device changes
    execute = function(domoticz, device)

        local icon = 7426    -- Rotating fan
        if device.state == 'Off' then
            icon = 20121     -- Stopped fan
        end
        
        appData = { appname = "Bathroom_fan",
                    text = device.state,
                    icon = icon 
                    }

        local appJSON = domoticz.utils.toJSON(appData)
        domoticz.log("Sending fan status to AWTRIX3: " .. appJSON, domoticz.LOG_INFO)
        
        local appDevice = domoticz.devices('AWTRIX3 - Send Custom App')
        if appDevice then
            appDevice.setDescription(appJSON)
            appDevice.switchOn().afterSec(2)
        else
            domoticz.log("'AWTRIX3 - Send Custom App' device not found", domoticz.LOG_ERROR)
        end
    end
}