mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Tweaks to the configurator UI
This commit is contained in:
parent
cdbcc844cf
commit
2016da984a
@ -10,9 +10,9 @@ A callback has to be provided to `request_config` which will be called when
|
|||||||
the user has submitted configuration information.
|
the user has submitted configuration information.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import threading
|
|
||||||
|
|
||||||
from homeassistant.helpers import generate_entity_id
|
from homeassistant.helpers import generate_entity_id
|
||||||
|
from homeassistant.const import EVENT_TIME_CHANGED
|
||||||
|
|
||||||
DOMAIN = "configurator"
|
DOMAIN = "configurator"
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
@ -155,14 +155,17 @@ class Configurator(object):
|
|||||||
|
|
||||||
entity_id = self._requests.pop(request_id)[0]
|
entity_id = self._requests.pop(request_id)[0]
|
||||||
|
|
||||||
|
# If we remove the state right away, it will not be included with
|
||||||
|
# the result fo the service call (current design limitation).
|
||||||
|
# Instead, we will set it to configured to give as feedback but delete
|
||||||
|
# it shortly after so that it is deleted when the client updates.
|
||||||
self.hass.states.set(entity_id, STATE_CONFIGURED)
|
self.hass.states.set(entity_id, STATE_CONFIGURED)
|
||||||
|
|
||||||
# If we remove the state right away, it will not be included with
|
def deferred_remove(event):
|
||||||
# the result fo the service call (limitation current design).
|
""" Remove the request state. """
|
||||||
# Instead we will set it to configured to give as feedback but delete
|
self.hass.states.remove(entity_id)
|
||||||
# it shortly after so that it is deleted when the client updates.
|
|
||||||
threading.Timer(
|
self.hass.bus.listen_once(EVENT_TIME_CHANGED, deferred_remove)
|
||||||
.001, lambda: self.hass.states.remove(entity_id)).start()
|
|
||||||
|
|
||||||
def handle_service_call(self, call):
|
def handle_service_call(self, call):
|
||||||
""" Handle a configure service call. """
|
""" Handle a configure service call. """
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||||
VERSION = "f299ce624d1641191f6f6a9b4b4d05bc"
|
VERSION = "d44fb74a23d83756ed92d5d55f4d81ea"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,28 @@
|
|||||||
|
<script src="../bower_components/moment/moment.js"></script>
|
||||||
|
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
|
<link rel="import" href="../components/state-info.html">
|
||||||
|
|
||||||
|
<polymer-element name="state-card-configurator" attributes="stateObj api" noscript>
|
||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
.state {
|
||||||
|
margin-left: 16px;
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-weight: 300;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div horizontal justified layout>
|
||||||
|
<state-info stateObj="{{stateObj}}"></state-info>
|
||||||
|
<div class='state'>{{stateObj.stateDisplay}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- pre load the image so the dialog is rendered the proper size -->
|
||||||
|
<template if="{{stateObj.attributes.description_image}}">
|
||||||
|
<img hidden src="{{stateObj.attributes.description_image}}" />
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</polymer-element>
|
@ -3,6 +3,7 @@
|
|||||||
<link rel="import" href="state-card-display.html">
|
<link rel="import" href="state-card-display.html">
|
||||||
<link rel="import" href="state-card-toggle.html">
|
<link rel="import" href="state-card-toggle.html">
|
||||||
<link rel="import" href="state-card-thermostat.html">
|
<link rel="import" href="state-card-thermostat.html">
|
||||||
|
<link rel="import" href="state-card-configurator.html">
|
||||||
|
|
||||||
<polymer-element name="state-card-content" attributes="api stateObj">
|
<polymer-element name="state-card-content" attributes="api stateObj">
|
||||||
<template>
|
<template>
|
||||||
|
@ -36,7 +36,6 @@ Polymer({
|
|||||||
/**
|
/**
|
||||||
* Whenever the attributes change, the more info component can
|
* Whenever the attributes change, the more info component can
|
||||||
* hide or show elements. We will reposition the dialog.
|
* hide or show elements. We will reposition the dialog.
|
||||||
* DISABLED FOR NOW - BAD UX
|
|
||||||
*/
|
*/
|
||||||
reposition: function(oldVal, newVal) {
|
reposition: function(oldVal, newVal) {
|
||||||
// Only resize if already open
|
// Only resize if already open
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<more-info-dialog id="moreInfoDialog" api={{api}}></more-info-dialog>
|
<more-info-dialog id="moreInfoDialog" api={{api}}></more-info-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
var domainsWithCard = ['thermostat'];
|
var domainsWithCard = ['thermostat', 'configurator'];
|
||||||
var domainsWithMoreInfo = ['light', 'group', 'sun', 'configurator'];
|
var domainsWithMoreInfo = ['light', 'group', 'sun', 'configurator'];
|
||||||
|
|
||||||
State = function(json, api) {
|
State = function(json, api) {
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
p.error {
|
p.error {
|
||||||
color: #C62828;
|
color: #C62828;
|
||||||
}
|
}
|
||||||
@ -44,7 +48,7 @@
|
|||||||
{{stateObj.attributes.errors}}
|
{{stateObj.attributes.errors}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p hidden?="{{!stateObj.attributes.description_image}}">
|
<p class='center' hidden?="{{!stateObj.attributes.description_image}}">
|
||||||
<img src='{{stateObj.attributes.description_image}}' />
|
<img src='{{stateObj.attributes.description_image}}' />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ Tests Configurator component.
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-public-methods,protected-access
|
# pylint: disable=too-many-public-methods,protected-access
|
||||||
import unittest
|
import unittest
|
||||||
import time
|
|
||||||
|
|
||||||
import homeassistant as ha
|
import homeassistant as ha
|
||||||
import homeassistant.components.configurator as configurator
|
import homeassistant.components.configurator as configurator
|
||||||
|
from homeassistant.const import EVENT_TIME_CHANGED
|
||||||
|
|
||||||
|
|
||||||
class TestConfigurator(unittest.TestCase):
|
class TestConfigurator(unittest.TestCase):
|
||||||
@ -109,7 +109,9 @@ class TestConfigurator(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(1, len(self.hass.states.all()))
|
self.assertEqual(1, len(self.hass.states.all()))
|
||||||
|
|
||||||
time.sleep(.02)
|
self.hass.bus.fire(EVENT_TIME_CHANGED)
|
||||||
|
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
self.assertEqual(0, len(self.hass.states.all()))
|
self.assertEqual(0, len(self.hass.states.all()))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user