<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Hi guys,</p>
<p>@Craig & Derek: Thanks for your input here! I didn't realize
the MQTT server working on a local LAN basis as well. I definitely
don't want anything in the internet. Although it means having
another service running somewhere as middle man between my HA and
OVMS.</p>
<p>Michael's command is what I was looking for. Just tested <i><font
size="+1"><tt><a class="moz-txt-link-freetext" href="http://192.168.4.1/api/execute?type=js&output=text&command=JSON.print(OvmsMetrics.GetValues(">http://192.168.4.1/api/execute?type=js&output=text&command=JSON.print(OvmsMetrics.GetValues(</a>""))</tt></font></i>
successfully. Don't even need the apikey as I don't have a PWD set
as OVMS has no AccessPoint started (OVMS is just in my local WiFi
with no internet connection).</p>
<p>So if I go down the polling route this is what I'm going to do.
Pushing would still be better though as I don't want my HA
(Arduino) to freeze for a couple of seconds when polling the car
and its not booked into my WiFi. Running a TCP server on my HA and
having OVMS push only when its in my WiFi is the more elegant
way... but also the more complex.</p>
<p>thanks guys</p>
<p>Soko<br>
</p>
<div class="moz-cite-prefix">On 24.08.2020 22:39, Michael Balzer
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:be189999-2a61-3d46-47af-e7460c2cc4e5@expeedo.de">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
Soko,<br>
<br>
the webserver REST API provides a simple command execution
endpoint you can use to execute Javascript code as well.<br>
<br>
See:<br>
- <a
href="https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/index.html#authorization"
moz-do-not-send="true">https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/index.html#authorization</a><br>
<br>
The scripting system has a simple metrics getter and JSON encoder.<br>
<br>
See:<br>
- <a
href="https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics"
moz-do-not-send="true">https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics</a><br>
- <a
href="https://docs.openvehicles.com/en/latest/userguide/scripting.html#json"
moz-do-not-send="true">https://docs.openvehicles.com/en/latest/userguide/scripting.html#json</a><br>
<br>
Example executing a shell command:<br>
<br>
<tt>-
<a class="moz-txt-link-freetext"
href="http://myovms.local/api/execute?apikey=mypassword&output=text&command=stat"
moz-do-not-send="true">http://myovms.local/api/execute?apikey=mypassword&output=text&command=stat</a></tt><br>
<br>
Example getting a single metric value:<br>
<br>
<tt>-
<a class="moz-txt-link-freetext"
href="http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=print(OvmsMetrics.Value("
moz-do-not-send="true">http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=print(OvmsMetrics.Value(</a>"v.b.soc"))</tt><br>
<br>
Examples getting multiple metrics JSON encoded:<br>
<br>
<tt>-
<a class="moz-txt-link-freetext"
href="http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=JSON.print(OvmsMetrics.GetValues("
moz-do-not-send="true">http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=JSON.print(OvmsMetrics.GetValues(</a>"m.net."))</tt><tt><br>
</tt><tt>-
<a class="moz-txt-link-freetext"
href="http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=JSON.print(OvmsMetrics.GetValues("
moz-do-not-send="true">http://myovms.local/api/execute?apikey=mypassword&type=js&output=text&command=JSON.print(OvmsMetrics.GetValues(</a>["v.c.charging","v.b.soc"]))</tt><br>
<br>
(URI encode as needed)<br>
<br>
Also see the scripting documentation and the plugin examples on
how to add custom modules providing custom commands.<br>
<br>
Of course you can also write data to files and poll those via
HTTP. That's one of the reasons the webserver provides access to
the file system. Write files in C++ as usual, see scripting object
VFS for script based file I/O.<br>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div class="moz-cite-prefix">Am 24.08.20 um 18:01 schrieb Soko:<br>
</div>
<blockquote type="cite"
cite="mid:b2d6da39-0840-8960-9e88-04f02ddd193c@soko.cc">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<p>Hi again,</p>
<p>Before I decide how to do this I would like to explore the
other way: My home automation is polling the data from OVMS.</p>
<p>I have had a look to the HTTP API. But it seems this is an
API for the server on the internet and not for OVMS itself,
correct?</p>
<p>Next option: My home automation does a simple HTTP-GET to
OVMS and reads data like this.<br>
Is there a way to read metrics like this?<br>
I have found the config->webserver site. I could point it
to an own dir like /store/data. Now I could write/update one
file there from my vehicle-module called "current" with all
the data I need. Then simply to a http-get to
192.168.4.1/current and I get the data of the file. Is it easy
- and most important: allowed - to write/update into a file in
OVMS.</p>
<p>thanks heaps for the input</p>
<p>Soko<br>
</p>
<div class="moz-cite-prefix">On 24.08.2020 01:46, Mark
Webb-Johnson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:9D3C90E6-942D-4E41-BEE5-0E37579AA08F@webb-johnson.net">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
The vehicle module is definitely the wrong place to do this.
<div class=""><br class="">
</div>
<div class="">If you really want to implement in C++, I
suggest you look at the ovms_server_v3 module. You could use
that as a template for what you need. It should periodically
read from the metrics, and send what you need to your home
automation.</div>
<div class=""><br class="">
</div>
<div class="">You should also consider a javascript plugin to
do this. That would probably be simpler and easier to update
(without firmware changes). If it is a common home
automation system, you could write it as a plugin and share
for others with the same system.</div>
<div class=""><br class="">
</div>
<div class="">Regards, Mark<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 24 Aug 2020, at 12:00 AM, Soko <<a
href="mailto:ovms@soko.cc" class=""
moz-do-not-send="true">ovms@soko.cc</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi Mark,<br class="">
<br class="">
I have my own home automation running at home. I
want to push the current values (SoC, odometer, ...)
once my car is in the driveway and OVMS is booked
into my WiFi. My home automation has a TCP server
running were I process the data further. <br
class="">
<br class="">
I don't want to the OVMS Server functionality as I'm
not a Linux guy, don't want the data in the internet
and no SIM use on the OVMS. <br class="">
<br class="">
So does the canlog_tcpclient.cpp take care of the
concurrency etc. correctly? I will do the same in my
code. Or should I start a separate task from the
vehicle task for every push?<br class="">
<br class="">
thx<br class="">
Soko<br class="">
<br class="">
<div class="gmail_quote">On 23 August 2020 16:37:46
CEST, Mark Webb-Johnson <<a
href="mailto:mark@webb-johnson.net" class=""
moz-do-not-send="true">mark@webb-johnson.net</a>>
wrote:
<blockquote class="gmail_quote" style="margin: 0pt
0pt 0pt 0.8ex; border-left: 1px solid rgb(204,
204, 204); padding-left: 1ex;">
<pre class="k9mail">What are you trying to do?
>From a design point of view, it seems strange to have an outgoing tcp connection from a vehicle module. Those modules need to be very responsive and realtime.
Mongoose is the correct approach. But take care, because most of the work is done in the network (not vehicle) task, so you need to deal with mutex and other concurrency issues.
Regards, Mark
<blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">On 23 Aug 2020, at 7:54 PM, Soko <<a href="mailto:ovms@soko.cc" class="" moz-do-not-send="true">ovms@soko.cc</a>> wrote:
Hey everyone,
I'm trying to send a simple tcp msg to a remote tcp-server. I've looked into the FreeRTOS example (esp-idf\examples\protocols\sockets\tcp_client\) which works (kinda) but OVMS behaves weirdly when I do it like that.
Thomas pointed me to mongoose...
So is this the way to go? I would take canlog_tcpclient.cpp as a model...
Ohh... and is it OK if I send my tcp msg in the vehcile task? Mongoose should take care of unforeseen errors so the task shouldn't block, right?
thx
Soko<hr class="">OvmsDev mailing list
<a href="mailto:OvmsDev@lists.openvehicles.com" class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" class="" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</blockquote><hr class="">OvmsDev mailing list
<a href="mailto:OvmsDev@lists.openvehicles.com" class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" class="" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
</div>
</div>
_______________________________________________<br
class="">
OvmsDev mailing list<br class="">
<a href="mailto:OvmsDev@lists.openvehicles.com"
class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br
class="">
<a class="moz-txt-link-freetext"
href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev"
moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br
class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<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" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
<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" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">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>
<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>
</body>
</html>