Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
f739316
Persist accessory state in a non-pickle format #12
ikalchev Feb 13, 2018
5afb0c2
Bugfix: Changed CurrentTemperature min/max values
cdce8p Feb 15, 2018
8547006
Merge pull request #28 from cdce8p/patch-1
ikalchev Feb 16, 2018
61a821b
Publishing should not fail with None brokers #27
ikalchev Feb 16, 2018
181cb0c
Issue #24 - Initial X-HM:// URI and QR Setup Code work
jslay88 Feb 16, 2018
2962a2d
Refactored to use HAP-NodeJS method.
jslay88 Feb 17, 2018
6fb0070
Changed str to byte string on the buffer to make that part work.
jslay88 Feb 17, 2018
14e7264
Added setup hash to advert, and randomly generating setup_id
jslay88 Feb 17, 2018
585dc2d
Unpack int from tuple
jslay88 Feb 17, 2018
7d14819
Add accessory to control Mac display status.
schinckel Feb 17, 2018
f77c301
First pass at all dynamic codes.
schinckel Feb 17, 2018
97bf6b5
Use easier-to-follow random selection.
schinckel Feb 17, 2018
57cfc52
Fixed setup_id generator.
jslay88 Feb 17, 2018
00437f0
Added QR code to main.py
jslay88 Feb 17, 2018
5baa57a
Made requested changes.
jslay88 Feb 17, 2018
2dc7374
Added setup_id to Bridge init and changed pow to use bitwise op
jslay88 Feb 17, 2018
377e84c
Merge pull request #34 from schinckel/dynamic-codes #24 #32
ikalchev Feb 17, 2018
51311fc
Merge branch 'master' into qrcode
jslay88 Feb 17, 2018
2d0fa65
Removed extra line added on accident.
jslay88 Feb 17, 2018
faee8b1
Merge pull request #33 from schinckel/display-switch
ikalchev Feb 17, 2018
67eb48d
Removed old pincode property for merge.
jslay88 Feb 17, 2018
da18db8
Merge pull request #30 from jslay88/qrcode #24
ikalchev Feb 17, 2018
b50134b
Fixed encoded_payload rjust
jslay88 Feb 17, 2018
e17e875
Merge pull request #38 from jslay88/master
ikalchev Feb 17, 2018
2a9426f
Allow easy way to store state files in user directories.
schinckel Feb 17, 2018
08d86b9
Show QR setup code only if not paired #24 #32.
ikalchev Feb 17, 2018
ab15752
Add latest Apple-defined HAP types #29
ikalchev Feb 18, 2018
86249dc
Add set_value callback toggle #19
ikalchev Feb 18, 2018
ea5c2df
Initial Sphinx Documentation Commit
jslay88 Feb 19, 2018
a4a84d6
Add docs README
jslay88 Feb 19, 2018
1ef5e56
Remove docs/build from .gitignore
jslay88 Feb 19, 2018
fe0692a
Merge pull request #47 from jslay88/sphinx #46
ikalchev Feb 19, 2018
25b0bed
Setup build dir for docs
jslay88 Feb 19, 2018
5015852
Merge pull request #48 from jslay88/sphinx
ikalchev Feb 19, 2018
241a4a6
Initial Travis CI Commit. (#1)
jslay88 Feb 19, 2018
ad5e8ab
Fix venv on .gitignore
jslay88 Feb 19, 2018
84924fa
Travis-CI setup
jslay88 Feb 19, 2018
82ac9b9
Update documentation for persist_file.
schinckel Feb 19, 2018
8ae29bb
Merge branch 'master' into expandvars
schinckel Feb 19, 2018
b44bf88
Merge pull request #39 from schinckel/expandvars
ikalchev Feb 19, 2018
8cbba14
Updating Documentation.
jslay88 Feb 19, 2018
2dac5c5
Updated docstring for merge on master.
jslay88 Feb 19, 2018
b9c24c5
Merge branch 'master' into sphinx2
jslay88 Feb 19, 2018
6a712d4
Made requested changes. Testing commit and build.
jslay88 Feb 19, 2018
12332e7
Codecov Reports
jslay88 Feb 19, 2018
d2a43b0
Add coverage to .gitignore
jslay88 Feb 19, 2018
8b73ea3
Allow easy way to store state files in user directories.
schinckel Feb 17, 2018
b5e03bc
Update documentation for persist_file.
schinckel Feb 19, 2018
93c608e
Updating Documentation.
jslay88 Feb 19, 2018
61a5602
Merge remote-tracking branch 'origin/sphinx2' into sphinx2
jslay88 Feb 19, 2018
49fd431
Omit accessories folder from codecov
jslay88 Feb 19, 2018
f5d617f
Removed unused testdata methods.
jslay88 Feb 19, 2018
10c4513
Merge pull request #50 from jslay88/master
ikalchev Feb 20, 2018
50f9ce3
Merge branch 'master' into sphinx2
jslay88 Feb 20, 2018
8538b9f
Fixed docstring.
jslay88 Feb 20, 2018
3c108b1
Added extra line for PEP8
jslay88 Feb 20, 2018
2c73cad
Travis CI build status - first commit.
ikalchev Feb 20, 2018
7197d03
Merge pull request #51 from jslay88/sphinx2
ikalchev Feb 20, 2018
d28de4a
Add coverage badge.
ikalchev Feb 20, 2018
3a637d4
Merge branch 'master' of https://github.com/ikalchev/HAP-python
ikalchev Feb 20, 2018
0d0bc07
Bump to 1.1.6, goes in pip
ikalchev Feb 20, 2018
c25ecd2
To trigger travis and readthedocs integrations.
ikalchev Feb 20, 2018
e18b6a2
Add readthedocs.io badge
ikalchev Feb 20, 2018
6415d1d
Fix RTD autodoc with relative path import
jslay88 Feb 21, 2018
3644f84
Removed incorrect dir now that make is explicitly whitelisted
jslay88 Feb 21, 2018
c04548f
Auto import HAP-python version for docs
jslay88 Feb 21, 2018
3ea9006
Fixed Typo
jslay88 Feb 21, 2018
0f847e0
Added Ubuntu Pre-Requisites to docs
jslay88 Feb 21, 2018
bd0ddd7
Cleaning up some docs.
jslay88 Feb 21, 2018
bb93447
Moved API into its own section on docs
jslay88 Feb 21, 2018
6ee2eaa
Restructured docs api
jslay88 Feb 21, 2018
34b918a
Merge pull request #55 from jslay88/RTDImportFix
ikalchev Feb 21, 2018
6abf6ef
Fix race condition #52
ikalchev Feb 21, 2018
e198f95
Added representations
cdce8p Feb 23, 2018
774af38
Small improvments
cdce8p Feb 23, 2018
c9d1520
Fixed typos
cdce8p Feb 24, 2018
b9969d5
Fixed wrong parameter
cdce8p Feb 24, 2018
71757b4
Merge pull request #56 from cdce8p/representations
ikalchev Feb 24, 2018
8130e14
Set should_notify to True after change from HomeKit
cdce8p Mar 22, 2018
08a9777
Added requirements file
cdce8p Mar 23, 2018
29032f3
Merge create_hap_template into to_HAP
cdce8p Mar 23, 2018
c0caa71
Add override properties method
cdce8p Mar 23, 2018
87c4235
Removed has_valid_values
cdce8p Mar 23, 2018
fb31281
Updated readme
cdce8p Mar 24, 2018
91ebaba
Added tests
cdce8p Mar 24, 2018
4f74008
Merge pull request #66 from cdce8p/char-template
ikalchev Mar 25, 2018
9b1d0fc
Merge pull request #65 from cdce8p/requirements
ikalchev Mar 25, 2018
260f951
Merge pull request #62 from cdce8p/patch-1
ikalchev Mar 25, 2018
0e1f684
Don't use AID=7 #61
ikalchev Mar 25, 2018
f6f862d
Comment about #61
ikalchev Mar 25, 2018
552ed45
Set default for 'valid_value' to 0
cdce8p Feb 25, 2018
ee0a164
Changed to min statement
cdce8p Mar 25, 2018
a99e232
Merge pull request #57 from cdce8p/valid-values
ikalchev Mar 25, 2018
7614496
Removed optional characteristics
cdce8p Mar 25, 2018
e7c1c65
Updated example accessories
cdce8p Mar 25, 2018
00f1fc3
Changed get_char method
cdce8p Mar 25, 2018
e1b2b3c
Updated tests
cdce8p Mar 25, 2018
c33482e
Removed get_value
cdce8p Mar 25, 2018
5391cd0
Merge pull request #67 from cdce8p/remove-opt-chars
ikalchev Mar 26, 2018
eaccedb
Add latest Apple-defined types #68
ikalchev Mar 29, 2018
67ce5f3
Bump version to 1.1.8
ikalchev Mar 29, 2018
a55edc0
Merge pull request #69 from ikalchev/master
ikalchev Mar 29, 2018
b3f3bc6
Remove breaking change description from README.
ikalchev Mar 29, 2018
fc24e2f
Merge branch 'dev' of https://github.com/ikalchev/HAP-python into dev
ikalchev Mar 29, 2018
a6ba6a4
Characteristic improvements (#73)
cdce8p Apr 6, 2018
58646a6
Bump version number to 1.1.9
ikalchev Apr 6, 2018
084bb73
Merge char improvements, doc changes, version 1.1.9 (#79)
ikalchev Apr 6, 2018
429dc27
Check for valid value after overriding properties (#82)
cdce8p Apr 13, 2018
d675c4b
[WIP] Move to coroutines for Accessory.run (#74)
ikalchev Apr 13, 2018
a99f104
Move scripts to separate folder (#81)
cdce8p Apr 14, 2018
e31a171
Event loop optimization (#83)
cdce8p Apr 15, 2018
5d82211
Service improvements (#84)
cdce8p Apr 15, 2018
39b240c
Enable travis for the dev branch
ikalchev Apr 16, 2018
4d79527
Removed py34 from travis (#87)
cdce8p Apr 16, 2018
f0b0276
Loader improvements (#85)
cdce8p Apr 16, 2018
e96da7c
Move constants to separate file (#86)
cdce8p Apr 16, 2018
8b273d6
Updated tests (#88)
cdce8p Apr 17, 2018
d4aa8d2
Fixed accessories (#89)
cdce8p Apr 17, 2018
149bfdb
Merge char improvements, doc changes, version 1.1.9 (#79) (#96)
cdce8p Apr 25, 2018
5214d45
Fix aio_stop_event (#93)
cdce8p Apr 25, 2018
d08cb9c
Added initial Changelog (#95)
cdce8p Apr 29, 2018
23e14e0
Improvements 1 - Characteristic (#99)
cdce8p Apr 30, 2018
355b8be
Improvements 2 - IID Manager (#100)
cdce8p Apr 30, 2018
930b6e6
Rearanged requirements (#101)
cdce8p Apr 30, 2018
a2e3d76
Improvements 6 - Changes, Driver (#104)
cdce8p May 1, 2018
8f5866b
Improvements 4 - Service Helper (#102)
cdce8p May 2, 2018
a11f5b3
Test backwards compatibility of Accessory._set_services (#106)
ikalchev May 2, 2018
78655d9
Improvements 5 - QR Code (#103)
cdce8p May 3, 2018
7e5e97a
Changed loader (#108)
cdce8p May 3, 2018
93d8f4f
Version bump to 2.0.0 (#109)
cdce8p May 4, 2018
aecb41a
Merge V2.0.0 into master (#110)
ikalchev May 4, 2018
01e1fe5
Merge branch 'dev' into master
ikalchev May 4, 2018
bd79baf
Merge master back into dev (#111)
ikalchev May 4, 2018
4bcc0b3
Fix typo in log message (#112)
lmarlow May 4, 2018
8e350cf
Fix typo in SDS011
ikalchev May 5, 2018
1197383
Documentation improvements for version 2.0.0 (#114)
ikalchev May 7, 2018
105bf6f
Replace event_loop with loop (#107)
cdce8p May 7, 2018
843bc83
Changelog update (#116)
cdce8p May 8, 2018
3b5d26e
Small changes - Accessory (#117)
cdce8p May 8, 2018
a03ce2f
Fix another typo in SDS011 which prevented pm10 from getting updates.
ikalchev May 9, 2018
98b2612
Merge branch 'dev' of https://github.com/ikalchev/HAP-python into dev
ikalchev May 9, 2018
c434ea9
Added getter_callback to Characteristic #78
jslay88 May 9, 2018
1ff502a
Fix typo bridge.to_HAP (#119)
cdce8p May 11, 2018
eed1d66
Adding Code Style Checker (#118)
cdce8p May 14, 2018
e92529a
Improvements 7 - Config class (#120)
cdce8p May 17, 2018
a6d5bb1
Remove the pyhap.accessories package. (#115)
ikalchev May 17, 2018
e9205d7
Release v2.1.0.
ikalchev May 18, 2018
d30a72a
V2.1.0 (#122)
ikalchev May 18, 2018
90a2995
Merge master back into dev (#123)
ikalchev May 18, 2018
1b86917
Improvements 6 - Driver assignment (#105)
cdce8p May 19, 2018
47c9ac7
Changes to organization files (#125)
cdce8p May 24, 2018
7d53e81
Improvements 8 - Async helper methods (#124)
cdce8p May 24, 2018
90e3a37
Version bump for release of v2.2.0 (#126)
ikalchev May 26, 2018
626092f
Merge branch 'dev' into v2.2.0
ikalchev May 26, 2018
694fb95
Merge pull request #127 from ikalchev/v2.2.0
ikalchev May 26, 2018
2696c30
Fix leftovers from the merge...
ikalchev May 26, 2018
10933d8
Fix package_data, bump version to 2.2.1 (#128)
cdce8p May 29, 2018
c515fcb
Merge pull request #129 from ikalchev/v2.2.1
ikalchev May 29, 2018
0d127c7
Fix spelling error
cdce8p May 29, 2018
ed85898
Removed pip install from release script
cdce8p May 29, 2018
d0ed617
Merge pull request #130 from cdce8p/fix-setup_cfg
ikalchev May 29, 2018
88f217b
Merge pull request #132 from ikalchev/v2.2.2
ikalchev May 29, 2018
7b6b4ee
Merge pull request #133 from ikalchev/master
ikalchev May 29, 2018
5e8a981
Unused import in README.md (#138)
thehappydinoa Jul 10, 2018
a806bd4
NeoPixelsLightStrip (#144)
LasCabos Sep 3, 2018
6272c7b
Fix set_characteristic #140 (#143)
ikalchev Sep 3, 2018
addb6aa
Make comment, code and warning match. (#150)
schinckel Sep 9, 2018
855577c
Add end_response in set_characteristics (Fix #153)
ikalchev Sep 23, 2018
dbf1d5d
Pull latest changes from HomeKit Simulator for Xcode 10
ikalchev Oct 4, 2018
f050ca3
Updated changelog (#157)
cdce8p Oct 4, 2018
85a952e
Add missing Accessory categories
ikalchev Oct 5, 2018
5986d13
Add camera support (beta) #53 (#98)
ikalchev Oct 5, 2018
2940f12
HAP-python integration for Adafruit NeoPixels (#155)
LasCabos Oct 7, 2018
561c516
Camera methods that allow custom start/stop/reconfigure of the stream.
ikalchev Oct 8, 2018
d87c953
Fix lints in test_camera
ikalchev Oct 8, 2018
447e416
Fix spelling executor (#159)
cdce8p Oct 12, 2018
681573e
Camera support (#161)
ikalchev Oct 23, 2018
41da9b1
Char - ignore duplicate values (#162)
cdce8p Oct 24, 2018
c2eaae6
Fix lints
ikalchev Oct 24, 2018
de4efec
Merge branch 'dev' of https://github.com/ikalchev/HAP-python into dev
ikalchev Oct 24, 2018
53fadfb
Update README and Changelog, add demo script
ikalchev Oct 24, 2018
9ec67c0
Correctly handle stream process stdout/err.
ikalchev Oct 24, 2018
a20e1ad
Fix test_camera.py
ikalchev Oct 24, 2018
7977ddf
Better docs for the options param to Camera
ikalchev Oct 24, 2018
955b1c6
Bump version to 2.3.0
ikalchev Oct 24, 2018
3227bde
Release v2.3.0 (#163)
ikalchev Oct 24, 2018
ee92c5b
Merge branch 'master' into dev
ikalchev Oct 24, 2018
69f18da
Camera improvements - stop and async
ikalchev Oct 31, 2018
43a729f
Revert char ignore duplicate values (#166)
cdce8p Nov 1, 2018
23c3c89
Temp disable 'update_advertisment' after pairing (#168)
cdce8p Nov 5, 2018
b103445
Add a child watcher only if in the main thread #169
ikalchev Nov 5, 2018
aa8f25a
Fix slow shutdown for python 3.7 (#167)
ikalchev Nov 6, 2018
1549717
Fix blocked sockets in CLOSE_WAIT state.
ikalchev Nov 10, 2018
a253a40
Moved metadata from setup.cfg to setup.py. Added long description
ikalchev Nov 10, 2018
fc8749f
Bump version to 2.4.0
ikalchev Nov 10, 2018
9f6e1ff
Release v2.4.0
ikalchev Nov 10, 2018
08250bd
Proxy calls to _io_refs in HAPSocket (#145)
ikalchev Nov 11, 2018
5709bb9
Bump version to 2.4.1
ikalchev Nov 11, 2018
31d4962
Release v2.4.1
ikalchev Nov 11, 2018
bd7638b
Also consider EBADF to be a timeout. Add some logging.
xbtsw Nov 23, 2018
864b98b
Add pypi download count in README.md
ikalchev Dec 3, 2018
76ba5df
Merge pull request #177 from xbtsw/socket
ikalchev Dec 7, 2018
353dc8a
Fixes for #176 and #172
ikalchev Jan 3, 2019
760a2ce
Merge branch 'dev' of https://github.com/ikalchev/HAP-python into dev
ikalchev Jan 3, 2019
625b92b
Fix lint errors
ikalchev Jan 4, 2019
b4d2f47
Bump version to 2.4.2
ikalchev Jan 4, 2019
5ac5b83
Merge pull request #180 from ikalchev/v2.4.2
ikalchev Jan 4, 2019
f3a95a5
add support for television (#187)
adrum Apr 9, 2019
0d7aef6
Bump version to 2.5.0
ikalchev Apr 10, 2019
291f175
Merge pull request #188 from ikalchev/v2.5.0
ikalchev Apr 10, 2019
2c5c596
Merge pull request #189 from ikalchev/master
ikalchev Apr 10, 2019
a0f5477
Make it possible to advertise custom service IP address (#203)
mback2k Sep 3, 2019
cc716fa
TV accessory (#202)
maximkulkin Sep 3, 2019
c20c87f
Ship version 2.6.0
ikalchev Sep 21, 2019
a7424c1
Merge pull request #206 from ikalchev/v2.6.0
ikalchev Sep 21, 2019
e845ad9
Merge pull request #207 from ikalchev/master
ikalchev Sep 21, 2019
60c849c
Fix typo in readme
spazm Nov 12, 2019
991761c
Merge pull request #210 from spazm/patch-1
ikalchev Nov 12, 2019
99db473
Fix multiple responses that are missing end_response
bdraco Dec 4, 2019
e5539ea
Create RPI_Relay.py
sanvd0000 Dec 7, 2019
1ac715d
Ensure events are not sent to the initiator client
bdraco Dec 4, 2019
fbabe83
Add support for HTTP/1.1 and random non-responsive devices #197
bdraco Dec 4, 2019
2d880ae
Merge pull request #216 from bdraco/http_11_keepalive_small
ikalchev Jan 25, 2020
f099cc4
Fix lint errors
ikalchev Jan 25, 2020
dbe58dc
Merge pull request #220 from sander-vd/patch-1
ikalchev Jan 25, 2020
4735de6
Merge pull request #217 from bdraco/multiple_errors_missing_end_response
ikalchev Jan 25, 2020
4bb331f
Merge pull request #215 from bdraco/avoid_send_events_to_sender_clien…
ikalchev Jan 26, 2020
51fbcff
Fix lint errors
ikalchev Jan 26, 2020
856c0fe
v2.7.0
ikalchev Jan 26, 2020
c8ffd07
Merge pull request #224 from ikalchev/v2.7.0
ikalchev Jan 26, 2020
8117856
Service callback for set_characteristics
bdraco Mar 19, 2020
52a1718
Switch to cryptography to resolve performance concerns.
bdraco Mar 27, 2020
214c047
Merge pull request #232 from bdraco/faster_crypto
ikalchev Mar 28, 2020
06f73da
Merge pull request #229 from bdraco/service_callback_brightness_fix
ikalchev Mar 28, 2020
8c38dbf
Add an example of service callbacks to README
bdraco Mar 28, 2020
c81a5fb
v2.8.0
ikalchev Apr 2, 2020
4973c12
Merge pull request #234 from ikalchev/v2.8.0
ikalchev Apr 2, 2020
ef89d07
Merge pull request #233 from bdraco/service_callbacks_example
ikalchev Apr 2, 2020
ae17ab9
Improve camera accessory integration (#231)
xdissent Apr 5, 2020
51cb473
Avoid disconnect on short read (#235)
bdraco Apr 6, 2020
2b2e4f3
v2.8.1
ikalchev Apr 6, 2020
fdc2c55
v2.8.1
ikalchev Apr 6, 2020
9d6ca40
Make service callbacks handle multiple aids
bdraco Apr 7, 2020
4eb1714
Merge pull request #237 from bdraco/set_char_multiple_aids
ikalchev Apr 10, 2020
7c3bbe1
Select zeroconf broadcast option
bdraco Apr 10, 2020
4668cd6
Merge pull request #239 from bdraco/zeroconf_select_broadcast_option
ikalchev Apr 10, 2020
6b6a6e4
Bump version to 2.8.2
ikalchev Apr 10, 2020
feba438
Merge pull request #240 from ikalchev/v2.8.2
ikalchev Apr 10, 2020
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
Prev Previous commit
Next Next commit
Publishing should not fail with None brokers ikalchev#27
Accessory.publish and Characteristic.notify should not fail when the
broker is not set. This is to allow updates to happen before the
Accessory is added to a driver or the Characteristic is added to an
Accessory.
  • Loading branch information
ikalchev committed Feb 16, 2018
commit 61a821b8d9c4f95f7b810de323329f4d50c19129
2 changes: 1 addition & 1 deletion pyhap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CHARACTERISTICS_FILE = os.path.join(_RESOURCE_DIR, "characteristics.json")
SERVICES_FILE = os.path.join(_RESOURCE_DIR, "services.json")

HAP_PYTHON_VERSION = (1, 1, 2)
HAP_PYTHON_VERSION = (1, 1, 3)
"""
HAP-python current version.
"""
5 changes: 5 additions & 0 deletions pyhap/accessory.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,17 @@ def publish(self, data, sender):

Characteristics call this method to send updates.

@note: The method will not fail if the broker is not set - it will do nothing.

@param data: Data to publish, usually from a Characteristic.
@type data: dict

@param sender: The Service or Characteristic from which the call originated.
@type: Service or Characteristic
"""
if self.broker is None:
return

acc_data = {
"aid": self.aid,
"iid": self.iid_manager.get_iid(sender),
Expand Down
19 changes: 17 additions & 2 deletions pyhap/characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class CharacteristicError(Exception):
pass


class NotConfiguredError(Exception):
"""Raised when an operation is attempted on a characteristic that has not been
fully configured.
"""
pass


_HAP_NUMERIC_FIELDS = {"maxValue", "minValue", "minStep", "unit"}
"""Fields that should be included in the HAP representation of the characteristic.

Expand Down Expand Up @@ -125,7 +132,8 @@ def set_value(self, value, should_notify=True):
@type value: Depends on properties["Format"]

@param should_notify: Whether a the change should be sent to subscribed clients.
The notification is called _after_ the setter callback.
The notification is called _after_ the setter callback. Notify will be
performed if and only if the broker is set, i.e. not None.
@type should_notify: bool

@raise ValueError: When the value being assigned is not one of the valid values
Expand All @@ -137,7 +145,7 @@ def set_value(self, value, should_notify=True):
self.value = value
if self.setter_callback is not None:
self.setter_callback(value)
if should_notify:
if should_notify and self.broker is not None:
self.notify()

def get_value(self):
Expand Down Expand Up @@ -166,7 +174,14 @@ def notify(self):
@note: Non-blocking, i.e. does not wait for the update to be sent.
@note: Uses the `get_hap_value`, i.e. sends the HAP value.
@see: accessory_driver.publish

@raise NotConfiguredError: When the broker is not set.
"""
if self.broker is None:
raise NotConfiguredError("Attempted to notify when `broker` is None. "
"Consider adding the characteristic to a "
"Service and then to an Accessory.")

data = {
"type_id": self.type_id,
"value": self.get_hap_value(),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name="HAP-python",
description="HomeKit Accessory Protocol implementation in python3",
author="Ivan Kalchev",
version="1.1.2",
version="1.1.3",
url="https://github.com/ikalchev/HAP-python.git",
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
8 changes: 8 additions & 0 deletions tests/test_accessory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
import pytest

import pyhap.accessory as accessory
import pyhap.loader as loader

class TestAccessory(object):

def test_init(self):
acc = accessory.Accessory("Test Accessory")

def test_publish_no_broker(self):
acc = accessory.Accessory("Test Accessory")
service = loader.get_serv_loader().get("TemperatureSensor")
char = service.get_characteristic("CurrentTemperature")
acc.add_service(service)
char.set_value(25, should_notify=True)

class TestBridge(TestAccessory):

def test_init(self):
Expand Down
9 changes: 6 additions & 3 deletions tests/test_characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ def test_default_valid_value():

def test_set_value():
char = get_char(PROPERTIES.copy())
char.broker = mock.Mock()
new_value = 3
char.set_value(new_value, should_notify=True)
char.set_value(new_value)
assert char.value == new_value
assert char.broker.publish.called

def test_set_value_valid_values():
valid_values = {"foo": 2, "bar": 3, }
Expand Down Expand Up @@ -71,3 +69,8 @@ def test_notify():
char.notify()
assert broker_mock.publish.called
broker_mock.publish.assert_called_with(expected, char)

def test_notify_except_no_broker():
char = get_char(PROPERTIES.copy())
with pytest.raises(characteristic.NotConfiguredError):
char.notify()