What could I have done wrong when updating Complications from my App?

Hello,

I have an app that takes data from a weather station API and dispkays it in a Widget. I now wanted to extend this to a Complication  to show it on watchfaces. I have defined two Complications in the resource XML file, and I am using the Complication.update(0,{value=>"This is a test"}); method, but with my data as String variables onstead of staric text, whenever I get new data.

However, in the Simulator, it always displays "--", which is a value I have once put into a Complication but since then it should have updated it countless times.

What do I have to do in order to make it work?

Best regards 

Aaron

  • When do you publish?  Must the widget be open and running?  For my weather ones, I have a background service that runs every "X" (configurable) minutes.

    If you run your widget in the sim. and look under simulation>complications, you'll see what you publish and the current value.

    Publishing is a bit tricky, in that the XML for complications used can only be included on devices with complications.  What does your xml for this look like?


  • I have the following XML:

    <complications> 
        <complication id="0" access="public" 
                      longLabel="@Strings.tempecowitt" 
                      shortLabel="@Strings.temp" 
                      glancePreview="true" 
                      icon = "@Drawables.ThermometerIcon"> 
            <faceIt defaultText="EcowittTemperatur" /> 
            <range> 
            </range> 
        </complication> 
        <complication id="1" access="public" 
                      longLabel="@Strings.windecowitt" 
                      shortLabel="@Strings.wind" 
                      glancePreview="false" 
                      icon = "@Drawables.WindIcon"> 
            <faceIt defaultText="EcowittWind" /> 
            <range> 
            </range> 
        </complication> 
    </complications>

    I publish it once, when the widget is loaded.

    My device is a Venu2, it is capable of using Complications....

  • what do you see in the sim when you run your widget under simulation>complications?

    Here's what I see with one of mine that publishes 4

    And if I select one, I see what's published for it

  • I see two Complications with the names I set, the Icons I set but instead of the values I published, I see "--" but the code that would publish "--" was never executed because it has a print statement before it, and I do not see the output of that print....

  • Sound like you're not publishing when you think you are.  Add some println calls in your widget, run it in the sim, and see what it's doing/not doing

    Requiring the user to run your widget so the watch face updates can be improved with a background service.

    By the way, the weather station I'm showing in the sim is actually an ecowitt one.  It uploads data to WU.

  • My app uses the Ecowitt API directly instead of WU. Once the publishing works, I'll also implement a background service, but I first need to get it to work in foreground....

    I added print calls and they were executed properly....

    That is a bit strange....

  • Try a different target device just in case.  Mine works fine for me on a venu2

    Induce a typo in your xml for complications, so you can make sure it's being used.

    Here's how I publish temperature if it's not null

            if(t!=null) {Complications.updateComplication(0, { :value => t });
  • I have the following code for publishing the Complications:

    var oTempNum=outdoor["temperature"]["value"].toNumber();
    System.print("Temp.: ");
    System.println(oTempNum);
    Complications.updateComplication(
    0,
    {
      "value" => oTempNum,
      "units" => Complications.UNIT_TEMPERATURE,
    }
    );
    var wSpNum=wind["wind_gust"]["value"].toNumber()/3.6;
    System.print("Wind: ");
    System.println(wSpNum);
    Complications.updateComplication(
    1,
    {
      "value" => wSpNum,
      "units" => Complications.UNIT_SPEED,
    }
    );

    I tried inducing a typo into the XML and it threw an error when building, so it is definitely being used.

    The XML file is named complications.xml and I placed it in the resources folder. It has the following content:

    <complications>
        <complication id="0" access="public"
                      longLabel="@Strings.tempecowitt"
                      shortLabel="@Strings.temp"
                      glancePreview="true"
                      icon = "@Drawables.ThermometerIcon">
            <faceIt defaultText="EcowittTemperatur" />
            <range>
            </range>
        </complication>
        <complication id="1" access="public"
                      longLabel="@Strings.windecowitt"
                      shortLabel="@Strings.wind"
                      glancePreview="false"
                      icon = "@Drawables.WindIcon">
            <faceIt defaultText="EcowittWind" />
            <range>
            </range>
        </complication>
    </complications>

    I also tried building for a Venu3 and running that in the simulator but it was the same (see screenshots):

  • With all my apps that publish, I do it from a background service.  That's a difference, but probably shouldn't matter,.  I'm also publishing Strings and not Numbers,  Try that.

    You'll also notice I don't set :units.  Try taking that out

    I posted a sample publisher a while back in https://forums.garmin.com/developer/connect-iq/f/discussion/353286/sample-of-ciq-complication-publisher-and-consumer-of-those-complications

    Maybe try that publisher in case something is odd with your setup

  • I just tried your publisher app, and it worked, at least on the Forerunner 965...

    I also tried adding the Venu 2 and running it on that, which does not work (the option "complications" in the sim is greyed out and not cklickable...

    When I ran my app on that Forerunner 965 (now without units and publishing Strings), it doesn't work at all and shows "--" for one and "-" for the other complication. I searched for "-" and "--" in all my app files and they were not found anywhere that had to do with complications...

    I don't really know what to do now...