mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
ozw: Rework and add some device specific drivers and examples.
This commit reworks ozw somewhat and adds some device specific drivers with examples. All of these drivers are kept in the UPM ozw library. The OZW class has been reworked to make it a proper singleton, since the OpenZWave::Manager() it depends on is already a singleton. This avoids issues such as opening and initializing OpenZWave multiple times. A new, relatively thin base class, ozwInterface is also now present. This class wraps some basic functionality, and handles initialization of the OZW base class. It is intended to be inherited by device driver classes. It operates on a node id for a device. Each OZW device is referenced by a node id, which does not change unless the device is removed (and possibly re-added) to a Z-Wave network. Finally, a series of device specific drivers have been implemented. These provide basic functionality to monitor and in some cases control the operation of a Z-Wave device. They are the following: ozwdump - This is a fake 'device' driver that initializes an OZW network and dumps information on all of the nodes (devices) present. Along with each node, available information on each valueid associated with that node is also printed. This fake device and it's examples replace the original ozw example. aeotecss6 - Aeotec Smart Switch 6. This device allows control of the switch, as well as reporting of information the switch makes available, such as current consumption, volts, watts, and accumulated energy use (kWh). aeotecsdg2 - Aeotec Smart Dimmer Gen 2. This device is similar to the Smart Switch 6, but also provides dimming functionality. It also provides information on energy use. aeotecdw2e - Aeotec Door/Window Sensor 2nd Edition. This device is a magnetic switch with an embedded tamper switch used to detect the opening/closing of windows and doors. This is a battery powered device. aeotecdsb09104 - Aeotec Home Energy Monitor. This device is intended to be installed at the MAINS or Breaker box. It reports current and cumulative energy consumption. tzemt400 - Trane TZEMT400 Thermostat. This device is a thermostat with Z-Wave functionality. The variant tested was the TZEMT400BB32MAA. The driver reports various information on the status of the thermostat, as well as the current measured temperature. Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
88
examples/python/aeotecdsb09104.py
Normal file
88
examples/python/aeotecdsb09104.py
Normal file
@ -0,0 +1,88 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
|
||||
# Instantiate an Aeotec DSB09104 instance, on device node 12. You
|
||||
# will almost certainly need to change this to reflect your own
|
||||
# network. Use the ozwdump example to see what nodes are available.
|
||||
sensor = sensorObj.AeotecDSB09104(12)
|
||||
|
||||
# The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate()
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
|
||||
print "Querying data..."
|
||||
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "Watts, Channel 1:",
|
||||
print sensor.getWattsC1(),
|
||||
print "W"
|
||||
|
||||
print "Watts, Channel 2:",
|
||||
print sensor.getWattsC2(),
|
||||
print "W"
|
||||
|
||||
print "Watts, Channel 3:",
|
||||
print sensor.getWattsC3(),
|
||||
print "W"
|
||||
|
||||
print "Energy, Channel 1:",
|
||||
print sensor.getEnergyC1(),
|
||||
print "kWh"
|
||||
|
||||
print "Energy, Channel 2:",
|
||||
print sensor.getEnergyC2(),
|
||||
print "kWh"
|
||||
|
||||
print "Energy, Channel 3:",
|
||||
print sensor.getEnergyC3(),
|
||||
print "kWh"
|
||||
|
||||
print "Battery Level:",
|
||||
print sensor.getBatteryLevel(),
|
||||
print "%"
|
||||
print
|
||||
time.sleep(3)
|
80
examples/python/aeotecdw2e.py
Normal file
80
examples/python/aeotecdw2e.py
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
|
||||
# Instantiate an Aeotec Door/Window 2nd Edition sensor instance, on
|
||||
# device node 10. You will almost certainly need to change this to
|
||||
# reflect your own network. Use the ozwdump example to see what nodes
|
||||
# are available.
|
||||
sensor = sensorObj.AeotecDW2E(10)
|
||||
|
||||
# The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate()
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
|
||||
print "Querying data..."
|
||||
|
||||
while (True):
|
||||
|
||||
if (sensor.isDeviceAvailable()):
|
||||
print "Alarm status:",
|
||||
print sensor.isAlarmTripped()
|
||||
|
||||
print "Tamper Switch status:",
|
||||
print sensor.isTamperTripped()
|
||||
|
||||
print "Battery Level:",
|
||||
print sensor.getBatteryLevel(),
|
||||
print "%"
|
||||
|
||||
print
|
||||
else:
|
||||
print "Device has not yet responded to probe."
|
||||
print "Try waking it, or wait until it wakes itself if ",
|
||||
print "configured to do so."
|
||||
|
||||
print
|
||||
|
||||
|
||||
time.sleep(1)
|
96
examples/python/aeotecsdg2.py
Normal file
96
examples/python/aeotecsdg2.py
Normal file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Turning switch off and sleeping for 5 seconds..."
|
||||
sensor.off()
|
||||
time.sleep(5)
|
||||
print "Exiting"
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
|
||||
# Instantiate an Aeotec Smart Dimmer Gen2 instance, on device node
|
||||
# 9. You will almost certainly need to change this to reflect your
|
||||
# own network. Use the ozwdump example to see what nodes are
|
||||
# available.
|
||||
sensor = sensorObj.AeotecSDG2(9)
|
||||
|
||||
# The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate()
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
|
||||
# turn light on
|
||||
print "Turning switch on, then sleeping for 5 secs"
|
||||
sensor.on();
|
||||
time.sleep(5);
|
||||
|
||||
print "Querying data..."
|
||||
dim = False;
|
||||
while (True):
|
||||
# put on a light show...
|
||||
if (dim):
|
||||
sensor.setLevel(25)
|
||||
else:
|
||||
sensor.on()
|
||||
|
||||
dim = not dim;
|
||||
|
||||
sensor.update()
|
||||
|
||||
print "Current Level:",
|
||||
print sensor.getLevel()
|
||||
|
||||
print "Volts:",
|
||||
print sensor.getVolts(),
|
||||
print "volts"
|
||||
|
||||
print "Energy Consumption:",
|
||||
print sensor.getEnergy(),
|
||||
print "kWh"
|
||||
|
||||
print "Watts:",
|
||||
print sensor.getWatts()
|
||||
|
||||
print "Current:",
|
||||
print sensor.getCurrent(),
|
||||
print "amps"
|
||||
|
||||
print
|
||||
time.sleep(5)
|
87
examples/python/aeotecss6.py
Normal file
87
examples/python/aeotecss6.py
Normal file
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Turning switch off and sleeping for 5 seconds..."
|
||||
sensor.off()
|
||||
time.sleep(5)
|
||||
print "Exiting"
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
|
||||
# Instantiate an Aeotec Smart Switch 6 instance, on device node 11.
|
||||
# You will almost certainly need to change this to reflect your own
|
||||
# network. Use the ozwdump example to see what nodes are available.
|
||||
sensor = sensorObj.AeotecSS6(11)
|
||||
|
||||
# The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate()
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
|
||||
# turn light on
|
||||
print "Turning switch on, then sleeping for 5 secs"
|
||||
sensor.on();
|
||||
time.sleep(5);
|
||||
|
||||
print "Querying data..."
|
||||
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "Switch status:",
|
||||
print sensor.isOn()
|
||||
|
||||
print "Volts:",
|
||||
print sensor.getVolts(),
|
||||
print "volts"
|
||||
|
||||
print "Energy Consumption:",
|
||||
print sensor.getEnergy(),
|
||||
print "kWh"
|
||||
|
||||
print "Watts:",
|
||||
print sensor.getWatts()
|
||||
|
||||
print "Current:",
|
||||
print sensor.getCurrent(),
|
||||
print "amps"
|
||||
|
||||
print
|
||||
time.sleep(3)
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
# Copyright (c) 2015-2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
@ -25,7 +25,7 @@ import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# Instantiate an OZW instance
|
||||
sensor = sensorObj.OZW()
|
||||
sensor = sensorObj.OZWDUMP()
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
@ -46,41 +46,39 @@ sensor.optionsLock()
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
if (not sensor.init(defaultDev)):
|
||||
print "Init failed."
|
||||
sys.exit(1)
|
||||
sensor.init(defaultDev)
|
||||
|
||||
print "Initialization complete"
|
||||
|
||||
print "Dumping nodes..."
|
||||
|
||||
sensor.dumpNodes()
|
||||
sensor.dumpNodes(True)
|
||||
|
||||
# The following is example output of dumpNodes:
|
||||
#
|
||||
# Dumping nodes...
|
||||
# Node 1: Z-Stick Gen5
|
||||
# Node 2: Smart Switch 6
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 2, Type: float, Label: Energy, Value: 1.190 kWh
|
||||
# Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh
|
||||
# Index: 4, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
# Index: 5, Type: float, Label: Power, Value: 0.000 W
|
||||
# Index: 6, Type: float, Label: Voltage, Value: 121.256 V
|
||||
# Index: 7, Type: float, Label: Current, Value: 0.000 A
|
||||
# Index: 8, Type: bool, Label: Exporting, Value: False
|
||||
# Index: 45, Type: list, Label: Day, Value: Friday
|
||||
# Index: 46, Type: byte, Label: Hour, Value: 5
|
||||
# Index: 47, Type: byte, Label: Minute, Value: 53
|
||||
# Index: 8, Type: bool, Label: Exporting, Value: False
|
||||
# Index: 45, Type: list, Label: Day, Value: Friday
|
||||
# Index: 46, Type: byte, Label: Hour, Value: 5
|
||||
# Index: 47, Type: byte, Label: Minute, Value: 53
|
||||
# Node 3: Multi Sensor
|
||||
# Index: 0, Type: bool, Label: Sensor, Value: True
|
||||
# Index: 0, Type: bool, Label: Sensor, Value: True
|
||||
# Index: 1, Type: float, Label: Temperature, Value: 72.8 F
|
||||
# Index: 2, Type: float, Label: Luminance, Value: 4 lux
|
||||
# Index: 3, Type: float, Label: Relative Humidity, Value: 22 %
|
||||
# Index: 17, Type: byte, Label: Battery Level, Value: 98 %
|
||||
# Node 5: Minimote
|
||||
# Node 6: Smart Energy Switch
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 2, Type: float, Label: Power, Value: 0.000 W
|
||||
# Index: 3, Type: float, Label: Energy, Value: 1.609 kWh
|
||||
# Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh
|
||||
@ -88,9 +86,9 @@ sensor.dumpNodes()
|
||||
# Index: 6, Type: float, Label: Power, Value: 0.000 W
|
||||
# Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W
|
||||
# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
# Index: 9, Type: bool, Label: Exporting, Value: False
|
||||
# Index: 9, Type: bool, Label: Exporting, Value: False
|
||||
# Node 7: Smart Energy Switch
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 0, Type: bool, Label: Switch, Value: False
|
||||
# Index: 2, Type: float, Label: Power, Value: 0.000 W
|
||||
# Index: 3, Type: float, Label: Energy, Value: 0.000 kWh
|
||||
# Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh
|
||||
@ -98,29 +96,4 @@ sensor.dumpNodes()
|
||||
# Index: 6, Type: float, Label: Power, Value: 0.000 W
|
||||
# Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W
|
||||
# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds
|
||||
# Index: 9, Type: bool, Label: Exporting, Value: False
|
||||
#
|
||||
# So, with the above in mind:
|
||||
#
|
||||
# 1. Query the temperature on node 3 and print it out (as a
|
||||
# string), along with the units of measure:
|
||||
#
|
||||
# print "Temperature:", sensor.getValueAsString(3, 1),
|
||||
# sensor->getValueUnits(3, 1)
|
||||
#
|
||||
# 2. query the same temperature as a float:
|
||||
#
|
||||
# temperature = sensor.getValueAsFloat(3, 1)
|
||||
#
|
||||
# 3. Turn on the light plugged into the switch on Node 7, wait 5
|
||||
# seconds, then turn it back off again:
|
||||
#
|
||||
# print "Turning ON node 7"
|
||||
# sensor.setValueAsBool(7, 0, true)
|
||||
#
|
||||
# print "Sleeping for 5 seconds";
|
||||
# time.sleep(5)
|
||||
#
|
||||
# print "Turning OFF node 7"
|
||||
# sensor.setValueAsBool(7, 0, false);
|
||||
|
||||
# Index: 9, Type: bool, Label: Exporting, Value: False
|
82
examples/python/tzemt400.py
Normal file
82
examples/python/tzemt400.py
Normal file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2016 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
|
||||
# Instantiate a TZEMT400 instance, on device node 13. You will
|
||||
# almost certainly need to change this to reflect your own network.
|
||||
# Use the ozwdump example to see what nodes are available.
|
||||
sensor = sensorObj.TZEMT400(13)
|
||||
|
||||
# The first thing to do is create options, then lock them when done.
|
||||
sensor.optionsCreate()
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
|
||||
print "Querying data..."
|
||||
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
|
||||
print "Mode:",
|
||||
print sensor.getMode()
|
||||
|
||||
print "Operating State:",
|
||||
print sensor.getOperatingState()
|
||||
|
||||
print "Heating Point:", sensor.getHeatingPointTemperature(), "C /",
|
||||
print sensor.getHeatingPointTemperature(True), "F"
|
||||
|
||||
print "Cooling Point:", sensor.getCoolingPointTemperature(), "C /",
|
||||
print sensor.getCoolingPointTemperature(True), "F"
|
||||
|
||||
print "Fan Mode:",
|
||||
print sensor.getFanMode()
|
||||
|
||||
print "Fan State:",
|
||||
print sensor.getFanState()
|
||||
|
||||
print
|
||||
time.sleep(5)
|
Reference in New Issue
Block a user