Site updated at 2015-05-10 06:58:26 UTC

This commit is contained in:
Paulus Schoutsen 2015-05-09 23:58:26 -07:00
parent 74090f6d57
commit f53c01f50d
39 changed files with 1082 additions and 282 deletions

View file

@ -255,6 +255,12 @@
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -278,12 +284,6 @@
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -223,6 +223,12 @@
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -246,12 +252,6 @@
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -230,6 +230,12 @@
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -253,12 +259,6 @@
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -235,6 +235,12 @@ Home Assistant now supports <code>--open-ui</code> and <code>--demo-mode</code>
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -258,12 +264,6 @@ Home Assistant now supports <code>--open-ui</code> and <code>--demo-mode</code>
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -253,6 +253,12 @@ Events are saved in a local database. Google Graphs is used to draw the graph. D
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -276,12 +282,6 @@ Events are saved in a local database. Google Graphs is used to draw the graph. D
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -231,6 +231,12 @@
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -254,12 +260,6 @@
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -218,6 +218,12 @@ YAML allows the use of lists, which should make the configuration file a bit mor
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -241,8 +247,6 @@ YAML allows the use of lists, which should make the configuration file a bit mor
</li>
</ul>
</section>

View file

@ -219,6 +219,12 @@ The old logo, the new detailed logo and the new simple logo.
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -238,12 +244,6 @@ The old logo, the new detailed logo and the new simple logo.
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -112,7 +112,7 @@
<time datetime="2015-03-11T19:36:00-07:00" pubdate data-updated="true"><i class="icon-calendar"></i> March 11, 2015</time>
<time datetime="2015-03-11T18:36:00-08:00" pubdate data-updated="true"><i class="icon-calendar"></i> March 11, 2015</time>
@ -265,6 +265,12 @@ An initial version of voice control for Home Assistant has landed. The current i
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -284,12 +290,6 @@ An initial version of voice control for Home Assistant has landed. The current i
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -112,7 +112,7 @@
<time datetime="2015-03-22T01:21:00-07:00" pubdate data-updated="true"><i class="icon-calendar"></i> March 22, 2015</time>
<time datetime="2015-03-22T00:21:00-08:00" pubdate data-updated="true"><i class="icon-calendar"></i> March 22, 2015</time>
@ -333,6 +333,12 @@ James Cole has also contributed support for <a href='https://pushover.net/'>the
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
@ -352,12 +358,6 @@ James Cole has also contributed support for <a href='https://pushover.net/'>the
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -349,6 +349,12 @@ James has also contributed support for integrating Transmission into Home Assist
<ul class="divided">
<li class="post">
<a href="/blog/2015/05/09/utc-time-zone-awareness/">UTC & Time zone awareness</a>
</li>
<li class="post">
@ -368,12 +374,6 @@ James has also contributed support for integrating Transmission into Home Assist
</li>
<li class="post">
<a href="/blog/2015/03/01/home-assistant-migrating-to-yaml/">Home Assistant moving to YAML</a>
</li>
</ul>
</section>

View file

@ -0,0 +1,338 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>UTC & Time zone awareness - Home Assistant</title>
<meta name="author" content="Paulus Schoutsen">
<meta name="description" content="The Home Assistant core now uses UTC as the internal date time.">
<meta name="viewport" content="width=device-width">
<link rel="canonical" href="https://home-assistant.io">
<meta property="fb:app_id" content="338291289691179">
<meta property="og:title" content="UTC & Time zone awareness">
<meta property="og:site_name" content="Home Assistant">
<meta property="og:url" content="https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/">
<meta property="og:type" content="website">
<meta property="og:description" content="The Home Assistant core now uses UTC as the internal date time.">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet">
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
<link rel='shortcut icon' href='/images/favicon.ico' />
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
</head>
<body >
<header>
<div class="grid-wrapper">
<div class="grid">
<div class="grid__item three-tenths lap-two-sixths palm-one-whole ha-title">
<a href="/" class="site-title">
<img width='40' src='/images/favicon-192x192.png'> Home Assistant
</a>
</div>
<div class="grid__item seven-tenths lap-four-sixths palm-one-whole">
<nav>
<input type="checkbox" id="toggle">
<label for="toggle" class="toggle" data-open="Main Menu" data-close="Close Menu"></label>
<ul class="menu pull-right">
<li>
<a href="/getting-started/">Getting started</a>
<ul>
<li><a href='/getting-started/'>Installing Home Assistant</a></li>
<li><a href='/getting-started/configuration.html'>Initial configuration</a></li>
<li><a href='/components/'>Component overview</a></li>
<li><a href='/getting-started/android.html'>Setting up Android</a></li>
</ul>
</li>
<li>
<a href="/developers/">Developers</a>
<ul>
<li><a href="/developers/architecture.html">Architecture</a></li>
<li><a href="/developers/frontend.html">Frontend development</a></li>
<li><a href="/developers/creating_components.html">
Creating components
</a></li>
<li><a href="/developers/add_new_platform.html">
Adding platform support
</a></li>
<li><a href="/developers/api.html">Rest API</a></li>
</ul>
</li>
<li><a href="/blog/">Blog</a></li>
<li><a href="https://groups.google.com/forum/#!forum/home-assistant-dev">Need help?</a></li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<div class="grid-wrapper">
<div class="grid grid-center">
<div class="grid__item two-thirds lap-one-whole palm-one-whole">
<article class="post">
<header>
<h1 class="title indent">UTC & Time zone awareness</h1>
<div class="meta clearfix">
<time datetime="2015-05-09T23:08:00-07:00" pubdate data-updated="true"><i class="icon-calendar"></i> May 9, 2015</time>
<span class="byline author vcard"><i class='icon-user'></i> Paulus Schoutsen</span>
<span><i class='icon-time'></i> two minutes reading time</span>
<span>
<i class="icon-tags"></i>
<ul class="tags unstyled">
<li><a class='category' href='/blog/categories/core/'>core</a></li>
</ul>
</span>
<a class='comments'
href="#disqus_thread"
>Comments</a>
</div>
</header>
<p>I have recently merged code to refactor Home Assistant to use only UTC times internally. A much needed refactor. I&rsquo;ve added some extra test coverage to time sensitive parts to ensure stability. The code has been live in the dev branch for the last 9 days and will be soon released to the master branch.</p>
<p>From now on all internal communication will be done in UTC: time changed events, datetime attributes of states, etc. To get the current time in UTC you can call <code>homeassistant.util.dt.utcnow()</code>. This is a timezone aware UTC datetime object. <a href="https://github.com/balloob/home-assistant/blob/dev/homeassistant/util/dt.py"><code>homeassistant.util.dt</code></a> is a new util package with date helpers.</p>
<p>There is also such a thing as local time. Local time is based on the time zone that you have setup in your <code>configuration.yaml</code>. Local times should only be used for user facing information: logs, frontend and automation settings in <code>configuration.yaml</code>.</p>
<h3>Setting up your time zone</h3>
<p>Setting up a time zone happens in <code>configuration.yaml</code>. If you have no time zone setup, it will be auto detected using the existing detection code using <a href="https://freegeoip.net">freegeoip.net</a>. You can find a list of compatible time zones on <a href="http://en.wikipedia.org/wiki/List_of_tz_database_time_zones">Wikipedia</a>.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='yaml'><span class='line'><span class="l-Scalar-Plain">homeassistant</span><span class="p-Indicator">:</span>
</span><span class='line'> <span class="l-Scalar-Plain">time_zone</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">America/Los_Angeles</span>
</span></code></pre></td></tr></table></div></figure>
<h3>Compatibility</h3>
<p>The changes to the code are mostly backwards compatible. The old <code>hass.track_time_change</code> and <code>hass.track_point_in_time</code> use now internally two new methods: <code>hass.track_utc_time_change</code> and <code>hass.track_point_in_utc_time</code>. The usage of the old methods have not changed and should be backwards compatible.</p>
<p>This refactor adds a new migration for the database adding a <code>utc_offset</code> column to events and states. This information is currently not used but can prove useful in the future when we start analyzing the historical data.</p>
<h3>Backwards incompatible stuff</h3>
<p>All built-in components have been upgraded. The following list is only for people that run custom components:</p>
<ul>
<li><code>hass.track_time_change</code> and <code>hass.track_point_in_time</code> will now return a time zone aware datetime object. Python does not allow comparing a naive with an aware datetime object.</li>
<li>the sun attributes for rising and setting are now in UTC. The methods <code>sun.next_rising(hass)</code> and <code>sun.next_setting(hass)</code> are backwards compatible, just be careful if you used to read the raw attributes.</li>
<li>the API sends all times in UTC. If you use anything else besides the frontend to talk to HA, make sure it handles it differently.</li>
</ul>
</article>
<section id="disqus">
<h3 class="indent title">Comments</h3>
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
</div>
<aside id="sidebar" class="grid__item one-third lap-one-whole palm-one-whole">
<div class="grid">
<section class="sharing aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">Share this post</h1>
<a href="//twitter.com/share"
class="twitter-share-button"
data-url="https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/"
data-counturl="https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/" >Tweet</a>
<div class="g-plusone" data-size="standard"></div>
<div class="fb-share-button" style='top: -6px;'
data-href="https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/"
data-layout="button_count">
</div>
</section>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '338291289691179',
xfbml : true,
version : 'v2.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<section id="recent-posts" class="aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">Other Posts</h1>
<ul class="divided">
<li class="post">
<a href="/blog/2015/04/25/release-notes/">Release notes for April 25, 2015</a>
</li>
<li class="post">
<a href="/blog/2015/03/22/release-notes/">Release notes for March 22, 2015</a>
</li>
<li class="post">
<a href="/blog/2015/03/11/release-notes/">Release notes for March 11, 2015</a>
</li>
<li class="post">
<a href="/blog/2015/03/08/new-logo/">New logo for Home Assistant</a>
</li>
</ul>
</section>
</div>
</aside>
</div>
</div>
<footer>
<div class="grid-wrapper">
<div class="grid">
<div class="grid__item">
<p class="copyright">
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a>, <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>. Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.</span>
</p>
</div>
</div>
</div>
</footer>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<script>
var _gaq=[['_setAccount','UA-57927901-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script>
var disqus_shortname = 'home-assistant';
// var disqus_developer = 1;
var disqus_identifier = 'https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/';
var disqus_url = 'https://home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/';
var disqus_script = 'embed.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
</body>
</html>