Page 1 of 1

Integrate Shelly Dimmer Gen3

Posted: Wednesday 29 January 2025 22:40
by marmachine
Suddenly it was released so i ordered a couple to replace my older (Gen1 and 2) ones that are sort of dying (dropping connection or not responding at all).

Not knowing what i was getting into, i found out that the device isn't as easy as it was before.... so i thought, the functionality "one-button-dimming" for example is kinda hidden, but still there... easily overlooked. I hate that! :lol: :oops:
Anyway, as much as it sounds like a developed new thing, freedom and all what we've ever wanted, my intention is to simply replace the old dimmers. Shelly claims compatibility, but it seems everything but compatible with Domoticz right now.

Maybe someone can point me to some helpfull information since Shelly helpdesk is kinda sad to be honest. I need to integrate the device into domoticz, using MQTT like it worked out of the box in the old days. How do i get it into Domoticz?
I just hope there is some script available to make it work like before, set and go... ?

Re: Integrate Shelly Dimmer Gen3

Posted: Thursday 30 January 2025 0:29
by waltervl
Use the Shelly teacher script. viewtopic.php?p=322662#p322662
It is not completely gen 3 compatible yet but the can be easily added.

Re: Integrate Shelly Dimmer Gen3

Posted: Thursday 30 January 2025 12:29
by marmachine
Just installed shellyteacher4domo and ran it... this first resulted in an error for this new device.
So i've created a new entry for the tag [shellydimmerg3] in mqtt_templates_gen2.txt so that it's recognized.
This specific file (mqtt_templates_gen2.txt) inside shellyteacher, takes care of MQTT mapping to allow applications to recognize the unknown hardware.

I am quite stuck with the syntax because i understand *shit* of what i see there... as it is a Gen3 device, things might be different and i don't know how to translate the device payload to a working template. Anyone with some knowlegde on that?

Raised an issue on Github : https://github.com/enesbcs/shellyteacher4domo/issues/65

P.s.: I did manage to get my Shelly 1 Gen 3 to work... the dimmer is just a different thing :|

Re: Integrate Shelly Dimmer Gen3

Posted: Thursday 02 April 2026 13:24
by Fdmekinabo
I disabled MQTT on Shellies and I am using this script to control them and read the state. Here is an example for two devices, Shelly Dimmer Gen3 and Shelly Plus RGBW PM. The script needs to be updated with a fixed IP of the device, the actual Domoticz name or IDX and if necessary channel number. You can also paste it into an AI and add in the same way other devices.

Code: Select all

return {
    on = {
        devices = { 'MYDIMMER3', 'MYRGBWDIMMER3' },
        timer = { 'every minute' },
        httpResponses = { 'shellyDimStatus', 'shellyRGBWStatus' }
    },
    execute = function(domoticz, triggeredItem)
        local shellies = {
            {
                idx = 2210,
                ip = '192.168.1.126',
                lightId = 0,
                statusCallback = 'shellyDimStatus'
            },
            {
                idx = 2211,
                ip = '192.168.1.150',
                lightId = 3,
                statusCallback = 'shellyRGBWStatus'
            }
        }

        if triggeredItem.isDevice then
            for _, shelly in ipairs(shellies) do
                if triggeredItem.idx == shelly.idx then
                    local state = triggeredItem.state
                    local level = triggeredItem.level or 0
                    local url

                    if state == 'Off' then
                        url = string.format('http://%s/rpc/Light.Set?id=%d&on=false', shelly.ip, shelly.lightId)
                    else
                        url = string.format('http://%s/rpc/Light.Set?id=%d&on=true&brightness=%d', shelly.ip, shelly.lightId, level)
                    end

                    os.execute('curl -s "' .. url .. '"')
                    break
                end
            end

        elseif triggeredItem.isTimer then
            for _, shelly in ipairs(shellies) do
                domoticz.openURL({
                    url = string.format('http://%s/rpc/Light.GetStatus?id=%d', shelly.ip, shelly.lightId),
                    method = 'GET',
                    callback = shelly.statusCallback
                })
            end

        elseif triggeredItem.isHTTPResponse and triggeredItem.ok then
            for _, shelly in ipairs(shellies) do
                if triggeredItem.callback == shelly.statusCallback then
                    local data = triggeredItem.json
                    local dev = domoticz.devices(shelly.idx)

                    if data.output == true then
                        if dev.level ~= data.brightness then
                            dev.dimTo(data.brightness)
                        end
                    else
                        if dev.active then
                            dev.switchOff()
                        end
                    end
                    break
                end
            end
        end
    end
}
Edit waltervl: make code a code block