Jump to content
WallDisplay: 2.0.0-beta3 is uploaded and ready for test ×

simulation of virtual components oin gen2 devices

Recommended Posts

  • Members
Posted (edited)

with such a script you can emulate virtual components on the MQTT interface of a gen 2 device:

const mqttPrefix = Shelly.getComponentConfig( "mqtt" ).topic_prefix;

let value = "off";

function showState()
    print( "send", value );
    MQTT.publish( mqttPrefix+"/status/enum:200", "{\"value\":\""+value+"\"}", 1, false );

MQTT.subscribe( mqttPrefix+"/rpc", 
        message = JSON.parse( message );
        if( message.method === "Enum.Set" && message.params.id == 200 )
            let answer = {
                id:     message.id,
                src:    mqttPrefix,
                dst:    message.src,
                result: {}
            value = message.params.value;
            MQTT.publish( message.src+"/rpc", JSON.stringify( answer ), 1, false );
    , null


the only drawback is, that you get two answers:

  1. error message from Shelly firmware
  2. result message from the script

so the master SW has to deal with this.

Edited by mschaeffler
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...