Skip to content

Commit

Permalink
Deploying to gh-pages from @ smarthomeNG/plugins@881a4c8 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
psilo909 committed Dec 31, 2023
1 parent ab8e4d6 commit 0854b6e
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 42 deletions.
50 changes: 32 additions & 18 deletions _sources/plugins/mvg_live/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
This plugin requires lib PyMVGLive. You can install this lib with:

```
sudo pip3 install PyMVGLive --upgrade
sudo pip3 install mvg --upgrade
```

This plugin provides functionality to query the data of www.mvg-live.de via the python package PyMVGLive.
This plugin provides functionality to query the data of www.mvv-muenchen.de via the python package "mvg" (pip install mvg).

Take care to not run it too often. My example below is manually triggered by a select action in the
smartVISU 2.9 select widget or a refresh button.
smartVISU 2.9 select widget including a refresh button.

Forum thread to the plugin: https://knx-user-forum.de/forum/supportforen/smarthome-py/1108867-neues-plugin-mvg_live

Expand Down Expand Up @@ -66,27 +67,40 @@ MVGWatch:

### mvg.py

For the images I am using https://commons.wikimedia.org/wiki/M%C3%BCnchen_U-Bahn?uselang=de and https://commons.wikimedia.org/wiki/Category:Line_numbers_of_Munich_S-Bahn
and put them in the dropins folder of smartVISU (/dropins/icons/myglive/Muenchen_%s.svg.png). %s is e.g. S8 or U3 and inputted from the departure array.
```html
results = sh.mvg_live.get_station_departures(sh.travel_info.mvg_station.search(), entries=15, bus=False, tram=False)
import logging
from datetime import datetime
from lib.shtime import Shtime
logger = logging.getLogger('mvg_info logics')
now = Shtime.get_instance().now()

results = sh.mvg_live.get_station_departures(sh.general.travel_info.mvg_station.search())
logger.error(results)
html_string = '<table>'
i = 1
for result in results:

dir_info = ''
line_string = '<tr><td style="width: 10px;"></td>'
line_string += '<td><img src="%s" alt="%s"/><td><td style="margin-left: 5px;"><img src="%s" alt="%s"/></td>' % (
result['productsymbolurl'], result['product'], result['linesymbolurl'], result['linename'])
line_string += '<td style="text-align: left; padding-left: 15px; width: 100%;">'
line_string += '%s </td>' % result['destination']
line_string += '<td style="color: #000; font-weight: bold; font-size: 25px;">'
line_string += '<div style="background-color: #fff; width: 30px; ">%i</div></td></tr>' % result['time']
html_string += line_string
i = i + 1
if i == 7:
break
for result in results:
if result['type'] in ["U-Bahn","S-Bahn"]:
result['linesymbolurl'] = 'https://<sv_dyndns_url>/smartVISU/dropins/icons/mvglive/Muenchen_%s.svg.png'%result['line']
dir_info = ''
line_string = '<tr><td style="width: 10px;"></td>'
line_string += '<td><img src="%s" alt="%s"/></td>' % (result['linesymbolurl'],result['linesymbolurl']) #<td><td style="margin-left: 5px;"><img src="%s" alt="%s"/>
line_string += '<td style="text-align: left; padding-left: 15px; width:60%;">'
line_string += '%s </td>' % result['destination']
line_string += '<td style="color: #000; font-weight: bold; font-size: 25px;">'
calculated_delay = ""
if int(datetime.fromtimestamp(result['time']-result['planned']).strftime("%M")) > 0:
calculated_delay = "(+%i)"%int(datetime.fromtimestamp(result['time']-result['planned']).strftime("%M"))
line_string += '<div style="background-color: #fff; width: 120px; ">%s %s</div></td></tr>' % (datetime.fromtimestamp(result['time']).strftime("%H:%M"),calculated_delay) #calculated_delay)
html_string += line_string
i = i + 1
if i == 7:
break

html_string += '</table>'
sh.travel_info.mvg_station.search.result(html_string)
sh.general.travel_info.mvg_station.search.result(html_string)
```

### smartVISU integration (Requires smartVISU 2.9, as select widget is used)
Expand Down
2 changes: 1 addition & 1 deletion _sources/plugins_doc/plugins_all.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
| | | | | |
| | | Plugin Typ: **protocol** | | |
+-------------------------------------------------------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+-----------------+
| :doc:`mvg_live <config/mvg_live>` | v1.5.1 | Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG) | psilo909 | ? |
| :doc:`mvg_live <config/mvg_live>` | v1.6.0 | Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG) | psilo909 | ? |
| | | | | |
| | | - `mvg_live zusätzliche Infos <http://smarthomeng.de/user/plugins_doc/config/mvg_live.html>`_ | | |
| | | - `mvg_live Unterstützung <https://knx-user-forum.de/forum/supportforen/smarthome-py/1108867-neues-plugin-mvg_live>`_ | | |
Expand Down
2 changes: 1 addition & 1 deletion _sources/plugins_doc/plugins_web.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
| | | | | |
| | | . | | |
+-------------------------------------------------------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+-----------------+
| :doc:`mvg_live <config/mvg_live>` | v1.5.1 | Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG) | psilo909 | ? |
| :doc:`mvg_live <config/mvg_live>` | v1.6.0 | Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG) | psilo909 | ? |
| | | | | |
| | | - `mvg_live zusätzliche Infos <http://smarthomeng.de/user/plugins_doc/config/mvg_live.html>`_ | | |
| | | - `mvg_live Unterstützung <https://knx-user-forum.de/forum/supportforen/smarthome-py/1108867-neues-plugin-mvg_live>`_ | | |
Expand Down
51 changes: 32 additions & 19 deletions plugins/mvg_live/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -5368,12 +5368,12 @@ <h1>mvg_live - MVG Live<a class="headerlink" href="#mvg-live-mvg-live" title="Pe
<section id="requirements">
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this heading"></a></h2>
<p>This plugin requires lib PyMVGLive. You can install this lib with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">pip3</span> <span class="n">install</span> <span class="n">PyMVGLive</span> <span class="o">--</span><span class="n">upgrade</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">pip3</span> <span class="n">install</span> <span class="n">mvg</span> <span class="o">--</span><span class="n">upgrade</span>
</pre></div>
</div>
<p>This plugin provides functionality to query the data of www.mvg-live.de via the python package PyMVGLive.
Take care to not run it too often. My example below is manually triggered by a select action in the
smartVISU 2.9 select widget or a refresh button.</p>
<p>This plugin provides functionality to query the data of www.mvv-muenchen.de via the python package „mvg“ (pip install mvg).</p>
<p>Take care to not run it too often. My example below is manually triggered by a select action in the
smartVISU 2.9 select widget including a refresh button.</p>
<p>Forum thread to the plugin: https://knx-user-forum.de/forum/supportforen/smarthome-py/1108867-neues-plugin-mvg_live</p>
</section>
<section id="configuration">
Expand Down Expand Up @@ -5431,26 +5431,39 @@ <h3>logics.yaml<a class="headerlink" href="#logics-yaml" title="Permalink to thi
</section>
<section id="mvg-py">
<h3>mvg.py<a class="headerlink" href="#mvg-py" title="Permalink to this heading"></a></h3>
<div class="highlight-html notranslate"><div class="highlight"><pre><span></span>results = sh.mvg_live.get_station_departures(sh.travel_info.mvg_station.search(), entries=15, bus=False, tram=False)
<p>For the images I am using https://commons.wikimedia.org/wiki/M%C3%BCnchen_U-Bahn?uselang=de and https://commons.wikimedia.org/wiki/Category:Line_numbers_of_Munich_S-Bahn
and put them in the dropins folder of smartVISU (/dropins/icons/myglive/Muenchen_%s.svg.png). %s is e.g. S8 or U3 and inputted from the departure array.</p>
<div class="highlight-html notranslate"><div class="highlight"><pre><span></span>import logging
from datetime import datetime
from lib.shtime import Shtime
logger = logging.getLogger(&#39;mvg_info logics&#39;)
now = Shtime.get_instance().now()

results = sh.mvg_live.get_station_departures(sh.general.travel_info.mvg_station.search())
logger.error(results)
html_string = &#39;<span class="p">&lt;</span><span class="nt">table</span><span class="p">&gt;</span>&#39;
i = 1
for result in results:

dir_info = &#39;&#39;
line_string = &#39;<span class="p">&lt;</span><span class="nt">tr</span><span class="p">&gt;&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;width: 10px;&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39;
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;%s&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;%s&quot;</span><span class="p">/&gt;&lt;</span><span class="nt">td</span><span class="p">&gt;&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;margin-left: 5px;&quot;</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;%s&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;%s&quot;</span><span class="p">/&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39; % (
result[&#39;productsymbolurl&#39;], result[&#39;product&#39;], result[&#39;linesymbolurl&#39;], result[&#39;linename&#39;])
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align: left; padding-left: 15px; width: 100%;&quot;</span><span class="p">&gt;</span>&#39;
line_string += &#39;%s <span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39; % result[&#39;destination&#39;]
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;color: #000; font-weight: bold; font-size: 25px;&quot;</span><span class="p">&gt;</span>&#39;
line_string += &#39;<span class="p">&lt;</span><span class="nt">div</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;background-color: #fff; width: 30px; &quot;</span><span class="p">&gt;</span>%i<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;&lt;/</span><span class="nt">tr</span><span class="p">&gt;</span>&#39; % result[&#39;time&#39;]
html_string += line_string
i = i + 1
if i == 7:
break
for result in results:
if result[&#39;type&#39;] in [&quot;U-Bahn&quot;,&quot;S-Bahn&quot;]:
result[&#39;linesymbolurl&#39;] = &#39;https://<span class="p">&lt;</span><span class="nt">sv_dyndns_url</span><span class="p">&gt;</span>/smartVISU/dropins/icons/mvglive/Muenchen_%s.svg.png&#39;%result[&#39;line&#39;]
dir_info = &#39;&#39;
line_string = &#39;<span class="p">&lt;</span><span class="nt">tr</span><span class="p">&gt;&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;width: 10px;&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39;
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;%s&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;%s&quot;</span><span class="p">/&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39; % (result[&#39;linesymbolurl&#39;],result[&#39;linesymbolurl&#39;]) #<span class="p">&lt;</span><span class="nt">td</span><span class="p">&gt;&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;margin-left: 5px;&quot;</span><span class="p">&gt;&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;%s&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;%s&quot;</span><span class="p">/&gt;</span>
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;text-align: left; padding-left: 15px; width:60%;&quot;</span><span class="p">&gt;</span>&#39;
line_string += &#39;%s <span class="p">&lt;/</span><span class="nt">td</span><span class="p">&gt;</span>&#39; % result[&#39;destination&#39;]
line_string += &#39;<span class="p">&lt;</span><span class="nt">td</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;color: #000; font-weight: bold; font-size: 25px;&quot;</span><span class="p">&gt;</span>&#39;
calculated_delay = &quot;&quot;
if int(datetime.fromtimestamp(result[&#39;time&#39;]-result[&#39;planned&#39;]).strftime(&quot;%M&quot;)) &gt; 0:
calculated_delay = &quot;(+%i)&quot;%int(datetime.fromtimestamp(result[&#39;time&#39;]-result[&#39;planned&#39;]).strftime(&quot;%M&quot;))
line_string += &#39;<span class="p">&lt;</span><span class="nt">div</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;background-color: #fff; width: 120px; &quot;</span><span class="p">&gt;</span>%s %s<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;&lt;/</span><span class="nt">td</span><span class="p">&gt;&lt;/</span><span class="nt">tr</span><span class="p">&gt;</span>&#39; % (datetime.fromtimestamp(result[&#39;time&#39;]).strftime(&quot;%H:%M&quot;),calculated_delay) #calculated_delay)
html_string += line_string
i = i + 1
if i == 7:
break

html_string += &#39;<span class="p">&lt;/</span><span class="nt">table</span><span class="p">&gt;</span>&#39;
sh.travel_info.mvg_station.search.result(html_string)
sh.general.travel_info.mvg_station.search.result(html_string)
</pre></div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion plugins_doc/plugins_all.html
Original file line number Diff line number Diff line change
Expand Up @@ -6325,7 +6325,7 @@
onkelandy</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="config/mvg_live.html"><span class="doc">mvg_live</span></a></p></td>
<td><p>v1.5.1</p></td>
<td><p>v1.6.0</p></td>
<td><p>Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG)</p>
<ul class="simple">
<li><p><a class="reference external" href="http://smarthomeng.de/user/plugins_doc/config/mvg_live.html">mvg_live zusätzliche Infos</a></p></li>
Expand Down
2 changes: 1 addition & 1 deletion plugins_doc/plugins_web.html
Original file line number Diff line number Diff line change
Expand Up @@ -5530,7 +5530,7 @@
Sandman60</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="config/mvg_live.html"><span class="doc">mvg_live</span></a></p></td>
<td><p>v1.5.1</p></td>
<td><p>v1.6.0</p></td>
<td><p>Abfrage der Abfahrten in Stationen der Münchner Verkehrsbetriebe (MVG)</p>
<ul class="simple">
<li><p><a class="reference external" href="http://smarthomeng.de/user/plugins_doc/config/mvg_live.html">mvg_live zusätzliche Infos</a></p></li>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 0854b6e

Please sign in to comment.