Beiträge von deboiph

    I finally found a way to get the on/off status based on the "apower" property of the notifications:

                "topics": {
                    "getOnline": "shellyplus1pm-XXXXXXXXXXXX/online",
                    "getOn": {
                        "topic": "shellyplus1pm-XXXXXXXXXXXX/events/rpc",
                        "apply": "if(message.includes('apower')) { return JSON.parse(message).params['switch:0'].apower==0 ? 'false' : 'true'; }"
    },
                    "setOn": {
                        "topic": "shellyplus1pm-XXXXXXXXXXXX/rpc",
                        "apply": "return JSON.stringify({id:1, src:'shellyplus1pm-XXXXXXXXXXXX', method:'Switch.Toggle', params:{id:0}})"
    }
    },
                "onlineValue": "true",
                "onValue": "true",

                "offValue": "off",


    Gen2 device API is really a step back compared to v1!
    Look at how easy it was with API v1 (below) compared to API v2 (above):

                "topics": {
                    "getOnline": "shellies/shelly1-XXXXXXXXXXXX/online",
                    "getOn": "shellies/shelly1-XXXXXXXXXXXX/relay/0",
                    "setOn": "shellies/shelly1-XXXXXXXXXXXX/relay/0/command"
    },
                "onlineValue": "true",
                "onValue": "on",
                "offValue": "off",

    As indicated in this article, using a single topic for all messages is an anti pattern of MQTT.

    Best,

    pHiL