Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  Exclude external libraries from code coverage
  Bug fixes for Wink
  Better positioning of dialogs
  Added error handling in frontend debug forms
  Integrate add worker to bootstrap.setup_component
  Conditionally show widgets on light more info
  Rename the edit state button in more info to debug
  Expect devices to have no name
  • Loading branch information
balloob committed Jan 16, 2015
2 parents aa9673b + db48b2b commit 93f93af
Show file tree
Hide file tree
Showing 23 changed files with 355 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ install:
script:
- flake8 homeassistant --exclude bower_components,external
- pylint homeassistant
- coverage run --source=homeassistant -m unittest discover tests
- coverage run --source=homeassistant --omit "homeassistant/external/*" -m unittest discover tests
after_success:
- coveralls
19 changes: 7 additions & 12 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import homeassistant
import homeassistant.loader as loader
import homeassistant.components as core_components

import homeassistant.components.group as group

_LOGGER = logging.getLogger(__name__)

Expand All @@ -35,6 +35,11 @@ def setup_component(hass, domain, config=None):

_LOGGER.info("component %s initialized", domain)

# Assumption: if a component does not depend on groups
# it communicates with devices
if group.DOMAIN not in component.DEPENDENCIES:
hass.pool.add_worker()

return True

else:
Expand Down Expand Up @@ -75,18 +80,8 @@ def from_config_dict(config, hass=None):
_LOGGER.info("Home Assistant core initialized")

# Setup the components

# We assume that all components that load before the group component loads
# are components that poll devices. As their tasks are IO based, we will
# add an extra worker for each of them.
add_worker = True

for domain in loader.load_order_components(components):
if setup_component(hass, domain, config):
add_worker = add_worker and domain != "group"

if add_worker:
hass.pool.add_worker()
setup_component(hass, domain, config)

return hass

Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def new_service_listener(service, info):
logger.info("Found new service: %s %s", service, info)

if component and component not in hass.components:
if bootstrap.setup_component(hass, component, config):
hass.pool.add_worker()
bootstrap.setup_component(hass, component, config)

hass.bus.fire(EVENT_PLATFORM_DISCOVERED, {
ATTR_SERVICE: service,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/http/frontend.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" DO NOT MODIFY. Auto-generated by build_frontend script """
VERSION = "b32ea78a1157b29555410384fe251dc9"
VERSION = "a82c6e4bf6b91042a6e891d46464275d"
21 changes: 16 additions & 5 deletions homeassistant/components/http/www_static/frontend.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Polymer({

cardClicked: function() {
this.api.showStateCardDialog(this.stateObj.entity_id);
this.api.showmoreInfoDialog(this.stateObj.entity_id);
},

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<polymer-element name="event-fire-dialog" attributes="api">
<template>

<ha-action-dialog id="dialog" heading="Fire Event" class='two-column'>
<ha-action-dialog
id="dialog"
heading="Fire Event"
class='two-column'
closeSelector='[dismissive]'>

<div layout horizontal>
<div class='ha-form'>
Expand Down Expand Up @@ -51,7 +55,9 @@
this.setEventType(eventType);
this.setEventData(eventData);

this.$.dialog.toggle();
this.job('showDialogAfterRender', function() {
this.$.dialog.toggle();
}.bind(this));
},

setEventType: function(eventType) {
Expand All @@ -68,15 +74,15 @@
},

clickFireEvent: function() {
var data;

if(this.$.inputData.value !== "") {
data = JSON.parse(this.$.inputData.value);
} else {
data = {};
try {
this.api.fire_event(
this.$.inputType.value,
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});
this.$.dialog.close();

} catch (err) {
alert("Error parsing JSON: " + err);
}

this.api.fire_event(this.$.inputType.value, data);
}
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
layered: true,
backdrop: true,
transition: 'core-transition-bottom',

domReady: function() {
this.addEventListener('core-overlay-open-completed', function() {
this.resizeHandler();
}.bind(this));
},
});
</script>
</polymer-element>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link rel="import" href="../cards/state-card-content.html">
<link rel="import" href="../more-infos/more-info-content.html">

<polymer-element name="state-card-dialog" attributes="api">
<polymer-element name="more-info-dialog" attributes="api">
<template>
<ha-action-dialog id="dialog">

Expand All @@ -20,24 +20,38 @@
<more-info-content stateObj="{{stateObj}}" api="{{api}}"></more-info-content>
</div>

<paper-button dismissive>Dismiss</paper-button>
<paper-button affirmative on-click={{editClicked}}>Edit State</paper-button>
<paper-button dismissive on-click={{editClicked}}>Debug</paper-button>
<paper-button affirmative>Dismiss</paper-button>
</ha-action-dialog>

</template>
<script>
Polymer({
stateObj: {},

// domReady: function() {
// this.$.dialog.addEventListener('core-overlay-open-completed', function() {
// this.$.dialog.resizeHandler();
// }.bind(this));
// },
observe: {
'stateObj.attributes': 'reposition'
},

/**
* Whenever the attributes change, the more info component can
* hide or show elements. We will reposition the dialog.
* DISABLED FOR NOW - BAD UX
*/
reposition: function(oldVal, newVal) {
// Only resize if already open
if(this.$.dialog.opened) {
this.job('resizeAfterLayoutChange', function() {
this.$.dialog.resizeHandler();
}.bind(this), 1000);
}
},

show: function(stateObj) {
this.stateObj = stateObj;
this.$.dialog.toggle();
this.job('showDialogAfterRender', function() {
this.$.dialog.toggle();
}.bind(this));
},

editClicked: function(ev) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<polymer-element name="service-call-dialog" attributes="api">
<template>

<ha-action-dialog id="dialog" heading="Call Service">
<ha-action-dialog
id="dialog"
heading="Call Service"
closeSelector='[dismissive]'>

<core-style ref='ha-dialog'></core-style>

Expand Down Expand Up @@ -45,14 +48,16 @@
Polymer({
ready: function() {
// to ensure callback methods work..
this.serviceSelected = this.serviceSelected.bind(this)
this.serviceSelected = this.serviceSelected.bind(this);
},

show: function(domain, service, serviceData) {
this.setService(domain, service);
this.$.inputData.value = serviceData;
// this.$.inputDataWrapper.update();
this.$.dialog.toggle();
this.job('showDialogAfterRender', function() {
this.$.dialog.toggle();
}.bind(this));
},

setService: function(domain, service) {
Expand All @@ -65,16 +70,17 @@
},

clickCallService: function() {
var data;

if(this.$.inputData.value != "") {
data = JSON.parse(this.$.inputData.value);
}

try {
this.api.call_service(
this.$.inputDomain.value,
this.$.inputService.value,
data);
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});

this.$.dialog.close();

} catch (err) {
alert("Error parsing JSON: " + err);
}
}
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@

<polymer-element name="state-set-dialog" attributes="api">
<template>
<ha-action-dialog id="dialog" heading="Set State">
<ha-action-dialog
id="dialog"
heading="Set State"
closeSelector='[dismissive]'>

<core-style ref='ha-dialog'></core-style>

<p>
This dialog will update the representation of the device within Home Assistant.<br />
This will not communicate with the actual device.
</p>

<div layout horizontal>
<div class='ha-form'>
<paper-input id="inputEntityID" label="Entity ID" floatingLabel="true" autofocus required></paper-input>
Expand Down Expand Up @@ -52,7 +60,9 @@
this.setState(state);
this.setStateData(stateData);

this.$.dialog.toggle();
this.job('showDialogAfterRender', function() {
this.$.dialog.toggle();
}.bind(this));
},

setEntityId: function(entityId) {
Expand All @@ -77,12 +87,18 @@
this.setStateData(state.attributes);
},

clickSetState: function() {
this.api.set_state(
this.$.inputEntityID.value,
this.$.inputState.value,
JSON.parse(this.$.inputData.value)
clickSetState: function(ev) {
try {
this.api.set_state(
this.$.inputEntityID.value,
this.$.inputState.value,
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {}
);

this.$.dialog.close();
} catch (err) {
alert("Error parsing JSON: " + err);
}
}
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="import" href="dialogs/event-fire-dialog.html">
<link rel="import" href="dialogs/service-call-dialog.html">
<link rel="import" href="dialogs/state-set-dialog.html">
<link rel="import" href="dialogs/state-card-dialog.html">
<link rel="import" href="dialogs/more-info-dialog.html">

<script>
var ha = {};
Expand Down Expand Up @@ -36,7 +36,7 @@
<event-fire-dialog id="eventDialog" api={{api}}></event-fire-dialog>
<service-call-dialog id="serviceDialog" api={{api}}></service-call-dialog>
<state-set-dialog id="stateSetDialog" api={{api}}></state-set-dialog>
<state-card-dialog id="stateCardDialog" api={{api}}></state-card-dialog>
<more-info-dialog id="moreInfoDialog" api={{api}}></more-info-dialog>
</template>
<script>
var domainsWithCard = ['thermostat'];
Expand Down Expand Up @@ -395,8 +395,8 @@
},

// show dialogs
showStateCardDialog: function(entityId) {
this.$.stateCardDialog.show(this.getState(entityId));
showmoreInfoDialog: function(entityId) {
this.$.moreInfoDialog.show(this.getState(entityId));
},

showEditStateDialog: function(entityId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
}
</style>

<div id='moreInfo'></div>
<div id='moreInfo' class='{{classNames}}'></div>
</template>
<script>
Polymer({
classNames: '',

observe: {
'stateObj.attributes': 'stateAttributesChanged',
},

stateObjChanged: function() {
while (this.$.moreInfo.lastChild) {
this.$.moreInfo.removeChild(this.$.moreInfo.lastChild);
Expand All @@ -25,8 +31,14 @@
var moreInfo = document.createElement("more-info-" + this.stateObj.moreInfoType);
moreInfo.api = this.api;
moreInfo.stateObj = this.stateObj;
this.$.moreInfo.appendChild(moreInfo);
}
this.$.moreInfo.appendChild(moreInfo);
},

stateAttributesChanged: function(oldVal, newVal) {
this.classNames = Object.keys(newVal).map(
function(key) { return "has-" + key; }).join(' ');
},

});
</script>
</polymer-element>
Loading

0 comments on commit 93f93af

Please sign in to comment.