Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get zha switch and binary_sensor state on HA start #11429

Closed
wants to merge 165 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
41fbfb5
Get zha switch state on HA start
Jan 3, 2018
86e1d0f
Account for User-Agent being non-existent, causing a TypeError (#11064)
akatrevorjay Jan 3, 2018
f314b6c
Cloud Updates (#11404)
balloob Jan 3, 2018
bb2191b
Add support for the renaming of Yamaha Receiver Zones via configurati…
dfinlay Jan 3, 2018
36c7fbe
Plex api update (#11423)
ryanm101 Jan 3, 2018
75a3935
fix: hmip-etrv-2 now working with homeassistant (#11175)
daenny Jan 3, 2018
ec700c2
Fix errors in zigbee push state (#11386)
Jan 3, 2018
eb00e54
Add on/off supported feature to climate (#11379)
andrey-git Jan 3, 2018
65df6f0
Fix CONF_FRIENDLY_NAME (#11438)
cdce8p Jan 3, 2018
4512a97
Climate: fix missing "|" (#11441)
andrey-git Jan 4, 2018
2cf5acd
Google Assistant -> Google Actions (#11442)
balloob Jan 4, 2018
04de226
Added new climate component from Daikin (#10983)
rofrantz Jan 4, 2018
4628a20
Get zha binary_switch state on HA start
Jan 4, 2018
3436676
Updated generic thermostat to respect operation_mode and added away m…
ciotlosm Jan 4, 2018
233e5ef
Lint fix
Jan 4, 2018
f54bba5
File permission revert
Jan 4, 2018
6cb0212
Reconnect to alarmdecoder on disconnect (#11383)
PhracturedBlue Jan 4, 2018
367d849
Ensure state ignores unknown data types
Jan 4, 2018
5680611
Filter to alarm attributes
Jan 4, 2018
c69e9e4
Fix formatting
Jan 4, 2018
35f3505
Set tahoma cover scan interval to 60 seconds (#11447)
bakedraccoon Jan 5, 2018
b7c7041
Add some tests to the cloud component (#11460)
balloob Jan 5, 2018
1e9e692
Input Select - Added service description (#11456)
cdce8p Jan 5, 2018
642e9c5
Input Boolean - Deleted 'DEFAULT_INITIAL' (#11453)
cdce8p Jan 5, 2018
1490ccf
Updated gitignore file (#11452)
cdce8p Jan 5, 2018
ebbdce1
Update hydroquebec component to use hass httpsession (#11412)
titilambert Jan 5, 2018
5236b72
Catch everything when calling to OctoPrint API to fix #10557 (#11457)
Jan 5, 2018
65d841c
Update PULL_REQUEST_TEMPLATE.md (#11465)
Danielhiversen Jan 5, 2018
71fb7a6
iOS 10 should be served javascript_version:es5 (#11387)
mnoorenberghe Jan 5, 2018
3a00c3d
Version bump to 0.60.1
balloob Jan 5, 2018
5820bab
Fix async IO in Sesame lock component. (#11054)
veleek Dec 22, 2017
e81d17d
Fix webdav calendar schema (#11185)
maxlaverse Dec 17, 2017
2330268
homematic: add username and password to interface config schema (#11214)
jannau Dec 19, 2017
9055922
Fix webostv select source (#11227)
OddBloke Dec 22, 2017
794cfb7
Fix detection of if a negative node is in use (#11255)
OverloadUT Dec 20, 2017
889eef7
Bugfix homematic available modus (#11256)
pvizeli Dec 20, 2017
5a469f4
Support multiple Hue bridges with lights of the same id (#11259)
andreacampi Dec 24, 2017
486263f
Fix inverted sensors on the concord232 binary sensor component (#11261)
CTLS Dec 21, 2017
f6a67d9
Fix handling zero values for state_on/state_off (#11264)
ziotibia81 Dec 21, 2017
a27b37b
Fix allday events in custom_calendars (#11272)
maxlaverse Dec 22, 2017
5d64554
Fix unpredictable entity names in concord232 binary_sensor (#11292)
rwa Dec 25, 2017
d3ed6d5
Fix leak sensors always showing Unknown until Wet (#11313)
OverloadUT Dec 27, 2017
e0a1b87
Don't block on sevice call for alexa (#11358)
pvizeli Dec 29, 2017
b611971
iOS 10 should be served javascript_version:es5 (#11387)
mnoorenberghe Jan 5, 2018
8b57777
Alexa to not use customize for entity config (#11461)
balloob Jan 5, 2018
c526fcd
Merge pull request #11470 from home-assistant/release-0-60-1
balloob Jan 5, 2018
0189678
Merge branch 'master' into dev
balloob Jan 5, 2018
455c629
Don't duplicate html5 registrations (#11451)
Chris-V Jan 5, 2018
417c193
AlarmDecoder remove icon function as BinarySensorDevice handles it co…
hawk259 Jan 5, 2018
f21914d
Upgrade psutil to 5.4.3 (#11468)
fabaff Jan 5, 2018
c714658
Upgrade alpha_vantage to 1.8.0 (#11476)
fabaff Jan 6, 2018
ff9688b
Fix vultr tests (#11477)
balloob Jan 6, 2018
f6307a1
Upgrade yarl to 0.17.0 (#11478)
fabaff Jan 6, 2018
a0df165
Add Touchline climate platform (#10547)
abondoe Jan 6, 2018
b22a268
Upgrade pysnmp to 4.4.4 (#11485)
fabaff Jan 6, 2018
3fbf09e
Add new iGlo component (#11171)
jesserockz Jan 6, 2018
c613585
Add missing configuration variables (#11390)
fabaff Jan 6, 2018
5c2cecd
Clean up Alexa.intent and DialogFlow.intent (#11492)
balloob Jan 7, 2018
939d1b5
Fix time functions would throw errors in python scripts (#11414)
tomwaters Jan 7, 2018
e42c485
Upgrade pywebpush to 1.5.0 (#11497)
Chris-V Jan 7, 2018
4496ee5
upgrade schiene to 0.20 (#11504)
JulianKahnert Jan 7, 2018
c203247
timer: include the remaining time in the state attributes (#11510)
Jan 7, 2018
efb83dd
More tolerant KNX component if gateway cant be connected (#11511)
Julius2342 Jan 7, 2018
4a6b5ba
Snips (new) added speech response, parse snips/duration (#11513)
tschmidty69 Jan 7, 2018
3cbd77f
Add Dark Sky weather component (#11435)
DanNixon Jan 7, 2018
8267a21
Lazy loading of service descriptions (#11479)
amelchio Jan 7, 2018
bccd880
Fix canary flaky test (#11519)
balloob Jan 7, 2018
c53fc94
Address missed review comments for Dark Sky weather (#11520)
DanNixon Jan 8, 2018
8c0035c
New features for Owntracks device_tracker (#11480)
cpcowart Jan 8, 2018
2ba9d82
Reconnect before mochad switch send command (#11296)
aosadchyy Jan 8, 2018
46ad194
Fix Kodi channels media type (#11505)
florianj1 Jan 8, 2018
dff36b8
Extension sensor alpha_vantage (#11427)
ChristianKuehnel Jan 8, 2018
b1b0a25
MQTT json attributes (#11439)
Jan 8, 2018
0e71009
Support pushing all sensors and fix wrong metrics. (#11159)
michaelkuty Jan 8, 2018
e0e2f73
Add options feature to Baidu TTS. (#11462)
yienxu Jan 8, 2018
903cda0
Insteon local update (#11088)
camrun91 Jan 8, 2018
13effee
Snips: (fix) support new intentName format (#11509)
tschmidty69 Jan 8, 2018
8b267e3
Upgrade numpy to 1.14.0 (#11542)
fabaff Jan 9, 2018
10f48fb
Upgrade python-etherscan-api to 0.0.2 (#11535)
fabaff Jan 9, 2018
8585888
Upgrade Sphinx to 1.6.6 (#11534)
fabaff Jan 9, 2018
13042d5
ZoneMinder event sensor updates (#11369)
swilson Jan 9, 2018
8313225
Move Google Assistant entity config out of customize (#11499)
balloob Jan 9, 2018
f56b3d8
Upgrade lightify to 1.0.6.1 (#11545)
fabaff Jan 9, 2018
cba5540
Improved test runtime (#11553)
cdce8p Jan 10, 2018
92014bf
Add 2 media_player services and 1 custom service to Squeezebox platfo…
ericpignet Jan 10, 2018
cf04a81
Fix error on entity_config missing (#11561)
philk Jan 10, 2018
c4bc42d
Upgrade keyring to 10.3.2 (#11531)
fabaff Jan 10, 2018
3cba09c
Coinbase.com sensor platform (#11036)
nkgilley Jan 10, 2018
4dda842
Try to fix crashes after Hue refactoring (#11270)
andreacampi Jan 10, 2018
88b70e9
Remove execution file perm (#11563)
balloob Jan 10, 2018
9e0ca71
Deprecate explicit entity_id in template platforms (#11123)
amelchio Jan 10, 2018
382a623
Update frontend to 20180110.0
balloob Jan 10, 2018
d793cfe
Update frontend to 20180110.0
balloob Jan 10, 2018
0d06e8c
Test tweaks (#11560)
balloob Jan 10, 2018
02979db
Add Velux Windows to Tahoma (#11538)
bakedraccoon Jan 10, 2018
c5d5d57
Extend hass.io services / updater (#11549)
pvizeli Jan 10, 2018
6cc285a
Add sensibo_assume_state service to Sensibo climate (#11567)
andrey-git Jan 10, 2018
60ce2b3
Tracking all groups to allow changing of existing groups (#11444)
randellhodges Jan 10, 2018
5fda78c
Fix new squeezebox service descriptions for lazy loading (#11574)
amelchio Jan 11, 2018
3972d1d
Mark REST binary_sensor unavailable if request fails (#11506)
DanNixon Jan 11, 2018
d2b6660
Tado improvements - hot water zone sensors and climate precision (#11…
andersonshatch Jan 11, 2018
cf612c3
Make the rpi_rf component thread-safe using an RLock (#11487)
ulido Jan 11, 2018
7723db9
Update pyhomematic, support new devices (#11578)
danielperna84 Jan 11, 2018
dc5b610
Alarmdecoder add validation of the zone types (#11488)
hawk259 Jan 11, 2018
3bc6a7d
Support OSRAM lights on ZHA (#11522)
emlove Jan 11, 2018
a23f603
Fix bluetooth tracker source (#11469)
swilson Jan 11, 2018
6b103cc
Fix for asuswrt, telnet not working and presence-detection for router…
kennedyshead Jan 11, 2018
a35d05a
Remove aux_heat support from Sensibo now that UI supports on/off (#11…
andrey-git Jan 11, 2018
1235dae
Changed device type of media player and cover to switch (#11483)
Laqoore Jan 11, 2018
6af42b4
Control ordering of display in history component (#11340)
rwa Jan 11, 2018
9384e2c
Pr/11430 (#11587)
balloob Jan 11, 2018
ed66c21
Cast return values and add unit tests for the yahoo weather component…
cgtobi Jan 11, 2018
2224d05
add velux roller shutter to tahoma (#11586)
bakedraccoon Jan 11, 2018
965bd8a
Added support for enable/disable motion detection (#11583)
abjorshammar Jan 11, 2018
4883036
Update frontend
balloob Jan 11, 2018
88161cd
Avoid returning empty media_image_url string (#11557)
JackWindows Jan 12, 2018
6918993
Fix state for trigger with forced updates (#11595)
emlove Jan 12, 2018
8a301c6
Concord232 alarm arm away fix (#11597)
rwa Jan 12, 2018
dacd7cd
Core support for hass.io calls & Bugfix check_config (#11571)
pvizeli Jan 12, 2018
cc23652
Fix Tahoma stop command for 2 types of shutters (#11588)
bakedraccoon Jan 12, 2018
b8e4c2f
Snips add say and say_actions services (new) (#11596)
tschmidty69 Jan 12, 2018
c036141
Pushbullet email support (fix) (#11590)
tschmidty69 Jan 12, 2018
0409192
Bugfix and cleanup for Rfxtrx (#11600)
Danielhiversen Jan 12, 2018
be31a86
Xiaomi lib upgrade (#11603)
Danielhiversen Jan 12, 2018
b854cdb
Upgrade yarl to 0.18.0 (#11609)
fabaff Jan 13, 2018
5656b0e
Upgrade keyring to 10.6.0 (#11608)
fabaff Jan 13, 2018
37427d0
Upgrad youtube_dl to 2017.12.31 (#11610)
fabaff Jan 13, 2018
5e81736
patch stop command (#11612)
bakedraccoon Jan 13, 2018
b2b836d
small sonos cleanup (#11607)
pvizeli Jan 13, 2018
e476b9d
Update Xiaomi Miio compontent broken URI (#11621)
keesschollaart81 Jan 13, 2018
2e08766
light/mqqt_json: allow brightness scaling (#11613)
jkoelker Jan 13, 2018
3e43f4e
Adding support for Lutron covers (#11602)
nickovs Jan 13, 2018
ea62ded
Update Pyarlo to 0.1.2 (#11626)
arsaboo Jan 13, 2018
5def6eb
Use kelvin/mireds correctly for setting iglo white (#11622)
jesserockz Jan 13, 2018
cdbf2f9
Hyperion: Add brightness, HDMI and effect support (#11543)
starkillerOG Jan 13, 2018
9d67d22
Fixes and enhancements for the Tahoma platform (#11547)
glpatcern Jan 13, 2018
c33b171
upgrade xiaomi lib (#11629)
Danielhiversen Jan 13, 2018
0550baa
Add templates to MQTT climate (#11623)
tinloaf Jan 14, 2018
028597f
Update CODEOWNERS
pvizeli Jan 14, 2018
688d706
Upgrade coinmarketcap to 4.1.2 (#11634)
fabaff Jan 14, 2018
033e068
Avoid returning empty media_image_url string (#11557)
JackWindows Jan 12, 2018
f2cc00c
Core support for hass.io calls & Bugfix check_config (#11571)
pvizeli Jan 12, 2018
1802c0a
Fix Tahoma stop command for 2 types of shutters (#11588)
bakedraccoon Jan 12, 2018
92bec56
Pushbullet email support (fix) (#11590)
tschmidty69 Jan 12, 2018
b8dfa4c
Fix state for trigger with forced updates (#11595)
emlove Jan 12, 2018
179d993
Snips add say and say_actions services (new) (#11596)
tschmidty69 Jan 12, 2018
8d19192
Concord232 alarm arm away fix (#11597)
rwa Jan 12, 2018
218e97d
Bugfix and cleanup for Rfxtrx (#11600)
Danielhiversen Jan 12, 2018
3afa472
Xiaomi lib upgrade (#11603)
Danielhiversen Jan 12, 2018
7a50450
Upgrade yarl to 0.18.0 (#11609)
fabaff Jan 13, 2018
d88edb0
patch stop command (#11612)
bakedraccoon Jan 13, 2018
7837b48
Use kelvin/mireds correctly for setting iglo white (#11622)
jesserockz Jan 13, 2018
9b15cfa
Update Pyarlo to 0.1.2 (#11626)
arsaboo Jan 13, 2018
c3ff5de
Merge pull request #11589 from home-assistant/release-0-61
fabaff Jan 15, 2018
f86b645
Merge branch 'master' into dev
fabaff Jan 15, 2018
3979387
Add Deconz support for Zigbee green power devices like Hue Tap (#11455)
Kane610 Jan 15, 2018
1ed0c7d
Bump dev to 0.62.0.dev0 (#11652)
fabaff Jan 15, 2018
fa4ffa8
Get zha switch state on HA start
Jan 3, 2018
8cdb1d5
Get zha binary_switch state on HA start
Jan 4, 2018
3d33a52
Lint fix
Jan 4, 2018
843cf18
File permission revert
Jan 4, 2018
28f0aaf
Ensure state ignores unknown data types
Jan 4, 2018
f9c539b
Filter to alarm attributes
Jan 4, 2018
3536530
Fix formatting
Jan 4, 2018
856b04a
Merge branch 'zha-switch-state' of github.com:SteveEasley/home-assist…
Jan 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion homeassistant/components/binary_sensor/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
pass

sensor = BinarySensor(device_class, **discovery_info)
async_add_devices([sensor])
async_add_devices([sensor], update_before_add=True)


class BinarySensor(zha.Entity, BinarySensorDevice):
Expand Down Expand Up @@ -87,3 +87,31 @@ def cluster_command(self, aps_frame, tsn, command_id, args):
elif command_id == 1:
_LOGGER.debug("Enroll requested")
self.hass.add_job(self._ias_zone_cluster.enroll_response(0, 0))

@asyncio.coroutine
def async_update(self):
"""Retrieve latest state."""
_LOGGER.debug("%s async_update", self.entity_id)

@asyncio.coroutine
def safe_read(cluster, attributes):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract this method and move it to the zha component and import it from there. There is no need to copy this method to every platform.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be wrong here but I think should_poll(self) -> bool: also needs to be overridden to return false on the base ZHA entity class. With debugging on, it appears that hass is calling the async_update functions that were added to these classes to poll for changes behind the scenes. The zigbee devices are already configured to push changes to hass when necessary to preserve battery life. I think leaving this as is will severly affect battery life of the sensors. @balloob, does this make sense? or am I way off base?

"""Swallow all exceptions from network read.

If we throw during initialization, setup fails. Rather have an
entity that exists, but is in a maybe wrong state, than no entity.
"""
try:
result, _ = yield from cluster.read_attributes(
attributes,
allow_cache=False,
)
return result
except Exception: # pylint: disable=broad-except
return {}

from bellows.types.basic import uint16_t

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file

result = yield from safe_read(self._endpoint.ias_zone, ['zone_status'])
state = result.get('zone_status', self._state)
if isinstance(state, (int, uint16_t)):
self._state = result.get('zone_status', self._state) & 3
31 changes: 28 additions & 3 deletions homeassistant/components/switch/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
DEPENDENCIES = ['zha']


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up Zigbee Home Automation switches."""
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the Zigbee Home Automation switches."""
discovery_info = zha.get_discovery_info(hass, discovery_info)
if discovery_info is None:
return

add_devices([Switch(**discovery_info)])
async_add_devices([Switch(**discovery_info)], update_before_add=True)


class Switch(zha.Entity, SwitchDevice):
Expand All @@ -47,3 +48,27 @@ def async_turn_off(self, **kwargs):
"""Turn the entity off."""
yield from self._endpoint.on_off.off()
self._state = 0

@asyncio.coroutine
def async_update(self):
"""Retrieve latest state."""
_LOGGER.debug("%s async_update", self.entity_id)

@asyncio.coroutine
def safe_read(cluster, attributes):
"""Swallow all exceptions from network read.

If we throw during initialization, setup fails. Rather have an
entity that exists, but is in a maybe wrong state, than no entity.
"""
try:
result, _ = yield from cluster.read_attributes(
attributes,
allow_cache=False,
)
return result
except Exception: # pylint: disable=broad-except
return {}

result = yield from safe_read(self._endpoint.on_off, ['on_off'])
self._state = result.get('on_off', self._state)