diff --git a/homeassistant/components/__init__.py b/homeassistant/components/__init__.py index a300e8b9e69..6acf178acb0 100644 --- a/homeassistant/components/__init__.py +++ b/homeassistant/components/__init__.py @@ -27,6 +27,9 @@ ATTR_ENTITY_ID = 'entity_id' # String with a friendly name for the entity ATTR_FRIENDLY_NAME = "friendly_name" +# A picture to represent entity +ATTR_ENTITY_PICTURE = "entity_picture" + STATE_ON = 'on' STATE_OFF = 'off' STATE_HOME = 'home' diff --git a/homeassistant/components/demo.py b/homeassistant/components/demo.py index 9d212e88d05..5e9976a3dc8 100644 --- a/homeassistant/components/demo.py +++ b/homeassistant/components/demo.py @@ -9,8 +9,8 @@ import random import homeassistant as ha import homeassistant.components.group as group from homeassistant.components import (SERVICE_TURN_ON, SERVICE_TURN_OFF, - STATE_ON, STATE_OFF, get_component, - extract_entity_ids) + STATE_ON, STATE_OFF, ATTR_ENTITY_PICTURE, + get_component, extract_entity_ids) from homeassistant.components.light import (ATTR_XY_COLOR, ATTR_BRIGHTNESS, GROUP_NAME_ALL_LIGHTS) from homeassistant.util import split_entity_id @@ -92,8 +92,13 @@ def setup(hass, config): hass.states.set("process.XBMC", STATE_ON) # Setup device tracker - hass.states.set("device_tracker.Paulus", "home") - hass.states.set("device_tracker.Anne_Therese", "not_home") + hass.states.set("device_tracker.Paulus", "home", + {ATTR_ENTITY_PICTURE: + "http://graph.facebook.com/schoutsen/picture"}) + hass.states.set("device_tracker.Anne_Therese", "not_home", + {ATTR_ENTITY_PICTURE: + "http://graph.facebook.com/anne.t.frederiksen/picture"}) + hass.states.set("group.all_devices", "home", { "auto": True, diff --git a/homeassistant/components/device_tracker.py b/homeassistant/components/device_tracker.py index 83fa1f176fb..7cd9e7729d4 100644 --- a/homeassistant/components/device_tracker.py +++ b/homeassistant/components/device_tracker.py @@ -61,7 +61,7 @@ def setup(hass, config): conf = config[DOMAIN] - if not ha.CONF_TYPE in conf: + if ha.CONF_TYPE not in conf: logger.error( 'Missing required configuration item in {}: {}'.format( DOMAIN, ha.CONF_TYPE)) @@ -175,7 +175,8 @@ class DeviceTracker(object): known_dev[device]['last_seen'] = now self.states.set( - known_dev[device]['entity_id'], components.STATE_HOME) + known_dev[device]['entity_id'], components.STATE_HOME, + known_dev[device]['default_state_attr']) # For all devices we did not find, set state to NH # But only if they have been gone for longer then the error time span @@ -185,7 +186,8 @@ class DeviceTracker(object): if now - known_dev[device]['last_seen'] > self.error_scanning: self.states.set(known_dev[device]['entity_id'], - components.STATE_NOT_HOME) + components.STATE_NOT_HOME, + known_dev[device]['default_state_attr']) # If we come along any unknown devices we will write them to the # known devices file but only if we did not encounter an invalid @@ -211,7 +213,8 @@ class DeviceTracker(object): writer = csv.writer(outp) if is_new_file: - writer.writerow(("device", "name", "track")) + writer.writerow(( + "device", "name", "track", "picture")) for device in unknown_devices: # See if the device scanner knows the name @@ -219,9 +222,10 @@ class DeviceTracker(object): name = (self.device_scanner.get_device_name(device) or "unknown_device") - writer.writerow((device, name, 0)) + writer.writerow((device, name, 0, "")) known_dev[device] = {'name': name, - 'track': False} + 'track': False, + 'picture': ""} except IOError: self.logger.exception(( @@ -253,6 +257,13 @@ class DeviceTracker(object): row['track'] = True if row['track'] == '1' else False + if row['picture']: + row['default_state_attr'] = { + components.ATTR_ENTITY_PICTURE: row['picture']} + + else: + row['default_state_attr'] = None + # If we track this device setup tracking variables if row['track']: row['last_seen'] = default_last_seen @@ -276,6 +287,8 @@ class DeviceTracker(object): row['entity_id'] = entity_id used_entity_ids.append(entity_id) + row['picture'] = row['picture'] + known_devices[device] = row if not known_devices: diff --git a/homeassistant/components/http/frontend.py b/homeassistant/components/http/frontend.py index 248acbd7060..89178662dd3 100644 --- a/homeassistant/components/http/frontend.py +++ b/homeassistant/components/http/frontend.py @@ -1,2 +1,2 @@ """ DO NOT MODIFY. Auto-generated by build_polymer script """ -VERSION = "0be01a612c785f83a9631d97b54d069a" +VERSION = "a460b05ee24f1e2372c820c552e815c3" diff --git a/homeassistant/components/http/www_static/frontend.html b/homeassistant/components/http/www_static/frontend.html index 00f045a2327..83810e9d8fe 100644 --- a/homeassistant/components/http/www_static/frontend.html +++ b/homeassistant/components/http/www_static/frontend.html @@ -17780,11 +17780,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN - + + @@ -17826,19 +17886,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN state-badge { float: left; cursor: pointer; - transition: background-color .2s ease-in-out, color .5s ease-in-out; } state-badge:hover { background-color: #039be5; } - /* Color the icon if light or sun is on */ - state-badge[data-domain=light][data-state=on], - state-badge[data-domain=sun][data-state=above_horizon] { - color: #fff176; - } - .name, .state.text { text-transform: capitalize; font-weight: 300; @@ -17877,7 +17930,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
- +
@@ -17952,20 +18005,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN stateChanged: function(oldVal, newVal) { this.stateUnknown = newVal == null; this.toggleChecked = newVal == "on" - - var state = this.stateObj; - - // for domain light, set color of icon to light color if available - if(state.domain == "light" && newVal == "on" && - state.attributes.brightness && state.attributes.xy_color) { - - var rgb = this.xyBriToRgb(state.attributes.xy_color[0], - state.attributes.xy_color[1], - state.attributes.brightness); - this.$.badge.style.color = "rgb(" + rgb.map(Math.floor).join(",") + ")"; - } else { - this.$.badge.style.color = null; - } }, turn_on: function() { @@ -17998,27 +18037,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN } }, - // from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb - xyBriToRgb: function (x, y, bri) { - z = 1.0 - x - y; - Y = bri / 255.0; // Brightness of lamp - X = (Y / y) * x; - Z = (Y / y) * z; - r = X * 1.612 - Y * 0.203 - Z * 0.302; - g = -X * 0.509 + Y * 1.412 + Z * 0.066; - b = X * 0.026 - Y * 0.072 + Z * 0.962; - r = r <= 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math.pow(r, (1.0 / 2.4)) - 0.055; - g = g <= 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math.pow(g, (1.0 / 2.4)) - 0.055; - b = b <= 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math.pow(b, (1.0 / 2.4)) - 0.055; - maxValue = Math.max(r,g,b); - r /= maxValue; - g /= maxValue; - b /= maxValue; - r = r * 255; if (r < 0) { r = 255 }; - g = g * 255; if (g < 0) { g = 255 }; - b = b * 255; if (b < 0) { b = 255 }; - return [r, g, b] - } }); @@ -18198,7 +18216,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN }, handleRefreshClick: function() { - this.api.fetchStates(); + this.api.fetchAll(); }, handleEventClick: function() { @@ -19977,11 +19995,55 @@ core-item { diff --git a/homeassistant/components/http/www_static/polymer/state-card.html b/homeassistant/components/http/www_static/polymer/state-card.html index 7296840b466..de28e762da0 100755 --- a/homeassistant/components/http/www_static/polymer/state-card.html +++ b/homeassistant/components/http/www_static/polymer/state-card.html @@ -27,19 +27,12 @@ state-badge { float: left; cursor: pointer; - transition: background-color .2s ease-in-out, color .5s ease-in-out; } state-badge:hover { background-color: #039be5; } - /* Color the icon if light or sun is on */ - state-badge[data-domain=light][data-state=on], - state-badge[data-domain=sun][data-state=above_horizon] { - color: #fff176; - } - .name, .state.text { text-transform: capitalize; font-weight: 300; @@ -79,10 +72,7 @@
@@ -158,20 +148,6 @@ stateChanged: function(oldVal, newVal) { this.stateUnknown = newVal == null; this.toggleChecked = newVal == "on" - - var state = this.stateObj; - - // for domain light, set color of icon to light color if available - if(state.domain == "light" && newVal == "on" && - state.attributes.brightness && state.attributes.xy_color) { - - var rgb = this.xyBriToRgb(state.attributes.xy_color[0], - state.attributes.xy_color[1], - state.attributes.brightness); - this.$.badge.style.color = "rgb(" + rgb.map(Math.floor).join(",") + ")"; - } else { - this.$.badge.style.color = null; - } }, turn_on: function() { @@ -204,27 +180,6 @@ } }, - // from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb - xyBriToRgb: function (x, y, bri) { - z = 1.0 - x - y; - Y = bri / 255.0; // Brightness of lamp - X = (Y / y) * x; - Z = (Y / y) * z; - r = X * 1.612 - Y * 0.203 - Z * 0.302; - g = -X * 0.509 + Y * 1.412 + Z * 0.066; - b = X * 0.026 - Y * 0.072 + Z * 0.962; - r = r <= 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math.pow(r, (1.0 / 2.4)) - 0.055; - g = g <= 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math.pow(g, (1.0 / 2.4)) - 0.055; - b = b <= 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math.pow(b, (1.0 / 2.4)) - 0.055; - maxValue = Math.max(r,g,b); - r /= maxValue; - g /= maxValue; - b /= maxValue; - r = r * 255; if (r < 0) { r = 255 }; - g = g * 255; if (g < 0) { g = 255 }; - b = b * 255; if (b < 0) { b = 255 }; - return [r, g, b] - } });