diff --git a/doc/devices_classes_branch.txt b/doc/devices_classes_branch.txt index 16d6d36..f38a515 100644 --- a/doc/devices_classes_branch.txt +++ b/doc/devices_classes_branch.txt @@ -203,6 +203,9 @@ whole record. +Note: callbacks on when_updated() might be required + + -------------------------------------------------------------------------------- PRESENT STATUS @@ -213,56 +216,31 @@ Registry tests all complete receive sequence counter tested setup_tool implemented and tested in simulation +fixed testers to use new registry and device classes +auto create example written using example registry -------------------------------------------------------------------------------- PLAN UP TO: MERGE BACK TO MASTER ----- DEMO APPS PHASE 1 - -For each of these, rewrite it in the assumption that you use setup_tool -to configure the system. - -fix: control_legacy.py -fix: control_mihome.py -fix: control_both.py -fix: monitor_mihome.py -fix: discover_mihome.py - ---- TEST ON REAL HARDWARE -Test registry and discovery on real hardware, and make sure it works as expected. -This will be a good first-look at what the better demos might look like. +Test device classes, factory, registry, router, discovery on real hardware. +Do this by testing the example apps * Test with real radio -* add back in the loop() call in the monitor_mihome.py program - - ----- DEMO APPS PHASE 2 - -(might do these after merge to master) - -mihome_energy_monitor.py -games_console_minder.py - - ----- EVENT HANDLERS ON DEVICES (later) - -(might do this as an improvement branch after merge to master) - -(add this as an issue of 'ideas for devices') -Need to get the core code out there, and improve it later - -aquarium.when_turned_off(just_turned_off) - +* Test with python 3 as well as python 2 ----- RELEASE TESTING AND RELEASE * update the test instructions and re-test everything before merge +* Any outstanding items on the list above, feed back into issues on the TODO list, +so that they get dealt with in a later pass + * merge to master after test END diff --git a/src/control_any_auto.py b/src/control_any_auto.py new file mode 100644 index 0000000..f334d48 --- /dev/null +++ b/src/control_any_auto.py @@ -0,0 +1,50 @@ +# control_any_auto.py 29/05/2016 D.J.Whale +# +# Demonstrates the variable auto-create. +# +# Variables are auto created into a given context, entirely from the registry. +# You should seed the registry first with setup_tool.py and give the devices +# the correct names, before this will work. + +import time +import energenie + +APP_DELAY = 1 + +def auto_loop(): + + # Use the auto-generated variables 'fan' and 'tv'. + # These can be any device that has a switch. + # They must be defined with these names in the registry for this code to work. + print("Turning ON") + fan.turn_on() + tv.turn_on() + time.sleep(APP_DELAY) + + print("Turning OFF") + fan.turn_off() + tv.turn_off() + time.sleep(APP_DELAY) + + + +if __name__ == "__main__": + + print("Starting auto example") + + energenie.init() + + # Load all devices into variables auto created in the global scope + # You can pass any context here, such as a class to contain your devices + import sys + me_global = sys.modules[__name__] + energenie.registry.load_into(me_global) + + try: + while True: + auto_loop() + + finally: + energenie.finished() + +# END diff --git a/src/energenie/KVS.py b/src/energenie/KVS.py index e593ce8..100e0bd 100644 --- a/src/energenie/KVS.py +++ b/src/energenie/KVS.py @@ -36,7 +36,7 @@ line = f.readline() if line == "": # EOF if command != None: - self.process(command, key, obj) + self.process(command, key, obj, create_fn) break # END else: line = line.strip() # remove nl diff --git a/src/registry.kvs b/src/registry.kvs index 202c072..e32c79e 100644 --- a/src/registry.kvs +++ b/src/registry.kvs @@ -1,12 +1,7 @@ -IGN tv +ADD tv type=MIHO005 device_id=1675 ADD fan type=ENER002 device_id=[822412, 1] - -ADD fred -type=MIHO005 -device_id=1675 -