Members mschaeffler Posted July 7 Members Share Posted July 7 (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", function(topic,message,ud) { //print(message) message = JSON.parse( message ); if( message.method === "Enum.Set" && message.params.id == 200 ) { let answer = { id: message.id, src: mqttPrefix, dst: message.src, result: {} }; print("set",message.params.value); value = message.params.value; MQTT.publish( message.src+"/rpc", JSON.stringify( answer ), 1, false ); showState(); } } , null ); showState(); print("started",mqttPrefix) the only drawback is, that you get two answers: error message from Shelly firmware result message from the script so the master SW has to deal with this. Edited July 7 by mschaeffler 1 Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.