Devices can now be polling or push

This commit is contained in:
Paulus Schoutsen committed 2015-02-28 22:33:44 -08:00
1 parent 8567dd001b
commit 8bd803601f
5 files changed
+38 -12

No files matched your search

+6 -3
View File
@@ -178,12 +178,14 @@ def setup(hass, config):
""" Add lights to the component to track. """
for light in new_lights:
if light is not None and light not in lights.values():
light.hass = hass
light.entity_id = generate_entity_id(
ENTITY_ID_FORMAT, light.name, lights.keys())
lights[light.entity_id] = light
light.update_ha_state(hass)
light.update_ha_state()
light_group.update_tracked_entity_ids(lights.keys())
@@ -201,7 +203,8 @@ def setup(hass, config):
_LOGGER.info("Updating light states")
for light in lights.values():
light.update_ha_state(hass, True)
if light.should_poll:
light.update_ha_state(True)
update_lights_state(None)
@@ -298,7 +301,7 @@ def setup(hass, config):
light.turn_on(**params)
for light in target_lights:
light.update_ha_state(hass, True)
light.update_ha_state(True)
# Update light state every 30 seconds
hass.track_time_change(update_lights_state, second=[0, 30])
+5 -2
View File
@@ -40,7 +40,8 @@ def setup(hass, config):
""" Update states of all sensors. """
if sensors:
for sensor in sensors.values():
sensor.update_ha_state(hass, True)
if sensor.should_poll:
sensor.update_ha_state(True)
update_sensor_states(None)
@@ -53,12 +54,14 @@ def setup(hass, config):
for sensor in discovered:
if sensor is not None and sensor not in sensors.values():
sensor.hass = hass
sensor.entity_id = generate_entity_id(
ENTITY_ID_FORMAT, sensor.name, sensors.keys())
sensors[sensor.entity_id] = sensor
sensor.update_ha_state(hass)
sensor.update_ha_state()
discovery.listen(hass, DISCOVERY_PLATFORMS.keys(), sensor_discovered)
+5 -3
View File
@@ -71,7 +71,7 @@ def setup(hass, config):
logger.info("Updating switch states")
for switch in switches.values():
switch.update_ha_state(hass, True)
switch.update_ha_state(True)
update_states(None)
@@ -88,12 +88,14 @@ def setup(hass, config):
for switch in discovered:
if switch is not None and switch not in switches.values():
switch.hass = hass
switch.entity_id = generate_entity_id(
ENTITY_ID_FORMAT, switch.name, switches.keys())
switches[switch.entity_id] = switch
switch.update_ha_state(hass)
switch.update_ha_state()
switch_group.update_tracked_entity_ids(switches.keys())
@@ -114,7 +116,7 @@ def setup(hass, config):
else:
switch.turn_off()
switch.update_ha_state(hass)
switch.update_ha_state(True)
# Update state every 30 seconds
hass.track_time_change(update_states, second=[0, 30])
@@ -82,7 +82,8 @@ def setup(hass, config):
logger.info("Updating thermostat state")
for thermostat in thermostats.values():
thermostat.update_ha_state(hass, True)
if thermostat.should_poll:
thermostat.update_ha_state(True)
# Update state every minute
hass.track_time_change(update_state, second=[0])
@@ -125,7 +126,7 @@ def setup(hass, config):
thermostat.set_temperature(temperature)
for thermostat in target_thermostats:
thermostat.update_ha_state(hass, True)
thermostat.update_ha_state(True)
hass.services.register(
DOMAIN, SERVICE_SET_AWAY_MODE, thermostat_service)