VoxCommando

Help and Support (Using VoxCommando) => Bug Reports => Topic started by: IKROWNI on January 14, 2017, 06:19:57 PM

Title: MQTT Not reconnecting
Post by: IKROWNI on January 14, 2017, 06:19:57 PM
I know its not so much a bug more than a slight irritant. When my mqtt server is restarted vox has to be manually reconnected by going into the plugin and clicking connect. Is there anyway for it to reconnect by itself when the server comes back up?
Title: Re: MQTT Not reconnecting
Post by: jitterjames on January 16, 2017, 06:43:49 PM
Although I did not put it into the action XML file yet there is actually an action:  MQTT.Connect which you can use instead of going into the plugin settings.  You could wire it up to a voice command.  I would recommend doing this instead of the following:

There are also events when MQTT connects and disconnects so in theory you could probably get VC to keep trying to reconnect.  When the MQTT broker is not reachable the MQTT.Connect action takes a long time to fail though so I'm not sure this is really the best idea.  Still it's up to you if you want to try it start with this and tweak as necessary:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.4-->
<commandGroup open="True" name="MQTT autoconnect" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="75" name="stop auto connect" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.StopEventTimer</cmdType>
      <params>
        <param>MQTT.Disconnected</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>MQTT.Connected</event>
  </command>
  <command id="56" name="++auto connect" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>MQTT.Connect</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Reconnected MQTT</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>120s</param>
            <param>MQTT.Disconnected</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>MQTT.Disconnected</event>
  </command>
</commandGroup>
Title: Re: MQTT Not reconnecting
Post by: IKROWNI on January 17, 2017, 06:44:04 PM
Thank you