<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
I've created a simple metric table example -- and found an old bug
in the update code by doing so :-)<br>
<br>
IOW, update before trying the example:<br>
<br>
<a class="moz-txt-link-freetext" href="https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/metrics.html#vector-tables">https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/metrics.html#vector-tables</a><br>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div class="moz-cite-prefix">Am 25.01.21 um 23:11 schrieb Michael
Balzer:<br>
</div>
<blockquote type="cite"
cite="mid:bf18aa18-10eb-65ea-643a-bd9db047b351@expeedo.de">sharkcow,
<br>
<br>
the "number" metric widget cannot handle vectors currently. The
"chart" and "table" widgets can, but need a little bit more
initialization work (see examples … a simple table example may
still be missing, I can create one if needed).
<br>
<br>
You can also register an event handler for "msg:metrics" and fill
your fields directly. Or extend the "metric number" widget to
support vector metrics.
<br>
<br>
A bar chart would visualize the relative tyre states nicely. You
could set the wheel names as category (X axis) labels and add the
alerts as a second series or colorize the bars by it (as I do with
the BMS chart).
<br>
<br>
Regards,
<br>
Michael
<br>
<br>
<br>
Am 25.01.21 um 22:34 schrieb sharkcow:
<br>
<blockquote type="cite">Michael,
<br>
<br>
thanks for your extensive response.
<br>
<br>
Regarding the WebPlugin, I seem to be lost... I just get the ol'
<br>
question mark if I use this:
<br>
<br>
<div class="metric number"
data-metric=metrics["v.t.health"][0]>
<br>
<span class="label">Tyre Health FL</span>
<br>
<span class="value">?</span>
<br>
<span class="unit"></span>
<br>
</div>
<br>
<br>
Tried all sorts of combinations with the quotes too... in the
shell the
<br>
metric is valid:
<br>
v.t.health 97.2549,97.2549,100,97.2549%
<br>
<br>
What am I missing?
<br>
<br>
Thanks!
<br>
<br>
sharkcow
<br>
<br>
<br>
Am 25.01.21 um 12:59 schrieb Michael Balzer:
<br>
<blockquote type="cite">sharkcow,
<br>
<br>
the metrics shell command currently only supports getting
& setting full
<br>
values, i.e. all values at once on a vector metric.
<br>
<br>
Workaround: use Javascript:
<br>
<br>
sc ev 'm="v.t.health"; v=OvmsMetrics.Value(m); v[2]=80;
<br>
OvmsCommand.Exec("met set "+m+" "+v);'
<br>
<br>
Not very handy that way. You can define a function for that in
your
<br>
ovmsmain.js:
<br>
<br>
function metricSetElem(metric, index, value) {
<br>
vector = OvmsMetrics.Value(metric);
<br>
vector[index] = value;
<br>
OvmsCommand.Exec("metric set " + metric + " " + vector);
<br>
}
<br>
<br>
…and then call it like this:
<br>
<br>
sc ev 'metricSetElem("v.t.health", 2, 80)'
<br>
<br>
Or you could add support to address single vector elements to
the
<br>
"metric" command.
<br>
<br>
OTOH, setting a metric manually is normally only needed during
<br>
development though, so you already have artificial test
values, why not
<br>
simply set the whole vector?
<br>
<br>
<br>
Regarding reading vector metrics in a web plugin, that's
straight
<br>
forward: the vector is stored as an array in the global
metrics object.
<br>
Addressing elements is as simple as…
<br>
<br>
metrics["v.t.health"][2]
<br>
<br>
…and of course you can do everything you normally can do with
an array.
<br>
<br>
Setting metric values from the web UI isn't a standard
operation, so you
<br>
need to call the "metrics" command for that here as well, e.g.
via
<br>
loadcmd().
<br>
<br>
Regards,
<br>
Michael
<br>
<br>
<br>
Am 25.01.21 um 09:07 schrieb sharkcow:
<br>
<blockquote type="cite">Hello all,
<br>
<br>
probably this is a stupid question, but can I set/read
individual
<br>
elements of an array on the command line? More importantly,
is there a
<br>
way to access individual elements in WebPlugins (I know I
could write a
<br>
script, but that seems to be overkill and I'd first have to
find out
<br>
exactly how to do it :-/)
<br>
<br>
Thanks!
<br>
<br>
sharkcow
<br>
<br>
<br>
Am 23.01.21 um 18:22 schrieb Michael Balzer:
<br>
<blockquote type="cite">It seems the list server still has
issues:
<br>
<br>
<br>
-------- Weitergeleitete Nachricht --------
<br>
Betreff: Re: [Ovmsdev] How does TPMS work now?
<br>
Datum: Mon, 18 Jan 2021 07:54:31 +0100
<br>
Von: Michael Balzer <a class="moz-txt-link-rfc2396E" href="mailto:dexter@expeedo.de"><dexter@expeedo.de></a>
<br>
An: <a class="moz-txt-link-abbreviated" href="mailto:ovmsdev@lists.openvehicles.com">ovmsdev@lists.openvehicles.com</a>
<br>
<br>
<br>
<br>
Craig,
<br>
<br>
vector metrics can (as all metrics btw) be set by their
string
<br>
representation, i.e.
<br>
<br>
metrics set v.t.pressure 210.29,210.29,210.29,210.29
<br>
<br>
…and all TPMS metrics (also the new ones) are persistent
now, see my
<br>
post "extended metrics persistence".
<br>
<br>
Regarding the sensor sets, I haven't used them yet, and
documentation is
<br>
lacking, so you need to check the source.
<br>
<br>
Regards,
<br>
Michael
<br>
<br>
<br>
Am 18.01.21 um 04:11 schrieb Craig Leres:
<br>
<blockquote type="cite">It used to be possible to manually
set tire pressure with:
<br>
<br>
metrics set v.tp.fl.p 210.29
<br>
metrics set v.tp.fr.p 210.29
<br>
metrics set v.tp.rl.p 210.29
<br>
metrics set v.tp.rr.p 210.29
<br>
<br>
but after upgrading to the latest persistent metrics
code I see these
<br>
are all gone.
<br>
<br>
I looked at the tpms command but it seems to be designed
to track
<br>
different sets of tpms sensor id numbers.
<br>
<br>
Is it possible to set these from the command line? Are
tpms tire
<br>
pressures (and temperatures) still persistent across
warm reboots? Is
<br>
my problem that these are stored in vectors now and
there is not yet a
<br>
way to manipulate them from the command line?
<br>
<br>
Craig
<br>
_______________________________________________
<br>
OvmsDev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
<br>
</blockquote>
<br>
-- <br>
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
<br>
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
<br>
<br>
<br>
<br>
<br>
-- <br>
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
<br>
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
<br>
<br>
<br>
_______________________________________________
<br>
OvmsDev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
<br>
<br>
</blockquote>
_______________________________________________
<br>
OvmsDev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
<br>
</blockquote>
<br>
<br>
_______________________________________________
<br>
OvmsDev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
<br>
<br>
</blockquote>
_______________________________________________
<br>
OvmsDev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
<br>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
</body>
</html>