<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>icon.zenith &#8211; SmartHomeNG | smarthome knx homematic mqtt hue 1wire home automation</title>
	<atom:link href="https://www.smarthomeng.de/tag/icon-zenith/feed" rel="self" type="application/rss+xml" />
	<link>https://www.smarthomeng.de</link>
	<description>Die Device Integrations-Plattform für Dein Smart Home</description>
	<lastBuildDate>Wed, 04 Apr 2018 19:40:54 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.5</generator>

<image>
	<url>https://www.smarthomeng.de/wp-content/uploads/global/logo_small_152x152-150x150.png</url>
	<title>icon.zenith &#8211; SmartHomeNG | smarthome knx homematic mqtt hue 1wire home automation</title>
	<link>https://www.smarthomeng.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Berechnung des Wertes für icon.zenith</title>
		<link>https://www.smarthomeng.de/berechnung-des-wertes-fuer-icon-zenith</link>
					<comments>https://www.smarthomeng.de/berechnung-des-wertes-fuer-icon-zenith#respond</comments>
		
		<dc:creator><![CDATA[Marc René Frieß]]></dc:creator>
		<pubDate>Wed, 04 Apr 2018 15:45:39 +0000</pubDate>
				<category><![CDATA[Beispiel-Implementierungen]]></category>
		<category><![CDATA[Tipps & Tricks]]></category>
		<category><![CDATA[icon.zenith]]></category>
		<category><![CDATA[smartVISU]]></category>
		<category><![CDATA[Sonnenstand]]></category>
		<guid isPermaLink="false">https://www.smarthomeng.de/?p=1355</guid>

					<description><![CDATA[Ein besonderes Merkmal der smartVISU sind dynamisch erzeugte SVG Dateien, die über die &#8222;icon&#8220;-Widget-Bibliothek genutzt werden können. Eine häufige Frage dabei ist, wie sich das icon.zenith, dass den aktuellen Sonnenstand darstellt, von SmartHomeNG aus bedaten lässt. Zwar bietet SmartHomeNG unter lib/env/location.yaml eine ganze Reihe Default-Items mit Werten zum Sonnenstand an,<a class="moretag" href="https://www.smarthomeng.de/berechnung-des-wertes-fuer-icon-zenith"> Weiterlesen&#8230;</a>]]></description>
										<content:encoded><![CDATA[<p>Ein besonderes Merkmal der <a href="http://www.smartvisu.de/" target="_blank" rel="noopener">smartVISU</a> sind dynamisch erzeugte SVG Dateien, die über die &#8222;icon&#8220;-Widget-Bibliothek genutzt werden können.</p>
<p>Eine häufige Frage dabei ist, wie sich das <code>icon.zenith</code>, dass den aktuellen Sonnenstand darstellt, von SmartHomeNG aus bedaten lässt.<br />
Zwar bietet SmartHomeNG unter <code>lib/env/location.yaml</code> eine ganze Reihe Default-Items mit Werten zum Sonnenstand an, jedoch sind diese für das <code>icon.zenith</code> nicht notwendig.</p>
<p>Dieses Kurz-Tutorial zeigt, wie sich der Wert für das Icon mit einer simplen Logik näherungsweise berechnen lässt.</p>
<h1>SmartHomeNG</h1>
<p>Basis ist ein einfaches numerisches Item namens <code>weather.sun.icon</code>:</p>
<pre><code class="language-yaml">weather:

    sun:

        icon:
            type: num
            visu_acl: ro
</code></pre>
<p>&nbsp;</p>
<p>Als nächstes wird unter <code>etc/logic.yaml</code> eine neue Logik eingehängt, die auf den Sonnenstand reagiert:</p>
<pre><code class="language-yaml">SunPositionLogic:
    filename: sun_position.py
    watch_item: env.location.sun_position.azimut.degrees
</code></pre>
<p>Die Logik löst also bei jeder Veränderng des System-Items <code>env.location.sun_position.azimut.degrees</code> aus. Dieses gibt den Sonnenstand in Grad wieder. Neben der untenstehenden Berechnung des Wertes für das &lt;code&gt;icon.zenith&lt;/code&gt; könnte man in der Logik auch noch weitere Sonnenstands-abhängige Aktionen einbinden, etwa das Herunterfahren von Rollläden.</p>
<p>&nbsp;</p>
<p>In der Logik-Datei <code>logics/sun_position.py</code> selber, werden nun sehr einfache Berechnungen vorgenommen:</p>
<pre><code class="language-python">
# Berechnungen für icon.zenith
now = datetime.datetime.utcnow().hour * 60 + datetime.datetime.utcnow().minute
sunrise = sh.sun.rise().hour * 60 + sh.sun.rise().minute
sunset = sh.sun.set().hour * 60 + sh.sun.set().minute
icon = int(round(255 * ((now - sunrise) / (sunset - sunrise)),0))

sh.weather.sun.icon(icon)
</code></pre>
<p>Über das Intervall vom Sonnenaufang bis zum Sonnenuntergang, wird der aktuelle Zeitpunkt auf eine Skala von 0 &#8211; 255 gemappt.</p>
<h1>smartVISU</h1>
<p>Dieser Wert dient nun als Basis für das <code>icon.zenith</code>, welches in der smartVISU wie folgt eingebunden wird:<br />
<code>{{ icon.zenith('weather.sun.icon', '', 'weather.sun.icon') }}</code>.<br />
Neben dem Icon kann man bspw. noch die aktuellen Daten des Sonnenwinkels anzeigen:</p>
<pre><code class="language-twig">
&lt;table&gt;
  &lt;tr&gt;
  &lt;td width="55px;"&gt; 
    {{ icon.zenith('weather.sun.icon', '', 'weather.sun.icon') }}
  &lt;/td&gt;
  &lt;td&gt; 
     H: {{ basic.print('env.location.sun_position.azimut', 'env.location.sun_position.azimut.degrees') }} ° 
  &lt;br/&gt;
     V: {{ basic.print('env.location.sun_position.elevation', 'env.location.sun_position.elevation.degrees') }} °
  &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
</code></pre>
<p>&nbsp;</p>
<p>Das fertige Ergebnis sieht nun wie folgt aus:</p>
<p><img decoding="async" src="https://www.smarthomeng.de/wp-content/uploads/2018/04/icon_zenith.png" alt="" class="alignnone size-full wp-image-1357" width="131" height="64" /></p>
<p>&nbsp;</p>
<p><em>(Die in diesem Artikel verwendeten Screenshots wurden selber erstellt. Das Titelbild ist unter der Creative Commons Zero (CC0) Lizenz veröffentlicht und wurde von www.pexels.com bezogen.)</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.smarthomeng.de/berechnung-des-wertes-fuer-icon-zenith/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
