<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I still think MQTT is the best way to handle IoT stuff like this. You will probably want to connect other things to your home automation as well, and MQTT is the standard for that (so you will probably end up with a local MQTT server at some point anyway).<div class=""><br class=""></div><div class="">Regarding the ovms server v3, you can simply leave it disabled in autostart. Then a one-line script on the wifi connect <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">event</span> to start the ovms server v3, and another on the wifi disconnect event to stop it.</div><div class=""><br class=""></div><div class="">Regards, Mark.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 25 Aug 2020, at 11:06 PM, Soko <<a href="mailto:ovms@soko.cc" class="">ovms@soko.cc</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252" class="">
  
  <div class=""><p class="">Hi guys,</p><p class="">@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 class="">Michael's command is what I was looking for. Just tested <i class=""><font size="+1" class=""><tt class=""><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 class="">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 class="">thanks guys</p><p class="">Soko<br class="">
    </p>
    <div class="moz-cite-prefix">On 24.08.2020 22:39, Michael Balzer
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:be189999-2a61-3d46-47af-e7460c2cc4e5@expeedo.de" class="">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252" class="">
      Soko,<br class="">
      <br class="">
      the webserver REST API provides a simple command execution
      endpoint you can use to execute Javascript code as well.<br class="">
      <br class="">
      See:<br class="">
      - <a href="https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/index.html#authorization" moz-do-not-send="true" class="">https://docs.openvehicles.com/en/latest/components/ovms_webserver/docs/index.html#authorization</a><br class="">
      <br class="">
      The scripting system has a simple metrics getter and JSON encoder.<br class="">
      <br class="">
      See:<br class="">
      - <a href="https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics" moz-do-not-send="true" class="">https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics</a><br class="">
      - <a href="https://docs.openvehicles.com/en/latest/userguide/scripting.html#json" moz-do-not-send="true" class="">https://docs.openvehicles.com/en/latest/userguide/scripting.html#json</a><br class="">
      <br class="">
      Example executing a shell command:<br class="">
      <br class="">
      <tt class="">-
        <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 class="">
      <br class="">
      Example getting a single metric value:<br class="">
      <br class="">
      <tt class="">-
        <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 class="">
      <br class="">
      Examples getting multiple metrics JSON encoded:<br class="">
      <br class="">
      <tt class="">-
        <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>"<a href="http://m.net" class="">m.net</a>."))</tt><tt class=""><br class="">
      </tt><tt class="">-
        <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 class="">
      <br class="">
      (URI encode as needed)<br class="">
      <br class="">
      Also see the scripting documentation and the plugin examples on
      how to add custom modules providing custom commands.<br class="">
      <br class="">
      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 class="">
      <br class="">
      Regards,<br class="">
      Michael<br class="">
      <br class="">
      <br class="">
      <div class="moz-cite-prefix">Am 24.08.20 um 18:01 schrieb Soko:<br class="">
      </div>
      <blockquote type="cite" cite="mid:b2d6da39-0840-8960-9e88-04f02ddd193c@soko.cc" class="">
        <meta http-equiv="Content-Type" content="text/html;
          charset=windows-1252" class=""><p class="">Hi again,</p><p class="">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 class="">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 class="">Next option: My home automation does a simple HTTP-GET to
          OVMS and reads data like this.<br class="">
          Is there a way to read metrics like this?<br class="">
          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 class="">thanks heaps for the input</p><p class="">Soko<br class="">
        </p>
        <div class="moz-cite-prefix">On 24.08.2020 01:46, Mark
          Webb-Johnson wrote:<br class="">
        </div>
        <blockquote type="cite" cite="mid:9D3C90E6-942D-4E41-BEE5-0E37579AA08F@webb-johnson.net" class="">
          <meta http-equiv="Content-Type" content="text/html;
            charset=windows-1252" class="">
          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 class=""><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 class="">
          <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 class="">
        <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 class="">
      <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 class="">
      <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>
  </div>

_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.openvehicles.com" class="">OvmsDev@lists.openvehicles.com</a><br class="">http://lists.openvehicles.com/mailman/listinfo/ovmsdev<br class=""></div></blockquote></div><br class=""></div></body></html>