Skip to content

Commit 16cd0be

Browse files
committed
add new ZWaveNodeThermostat class
1 parent 1306eca commit 16cd0be

2 files changed

Lines changed: 157 additions & 2 deletions

File tree

‎src-api/openzwave/command.py‎

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,159 @@ def get_sensor_value(self, value_id):
666666
return self.values[value_id].data
667667
return None
668668

669+
670+
class ZWaveNodeThermostat(ZWaveNodeInterface):
671+
"""
672+
Represents an interface to Thermostat Commands
673+
674+
"""
675+
676+
def get_thermostats(self, type='All'):
677+
"""
678+
The command 0x40 (COMMAND_CLASS_THERMOSTAT_MODE) of this node.
679+
The command 0x42 (COMMAND_CLASS_THERMOSTAT_OPERATING_STATE) of this node.
680+
The command 0x43 (COMMAND_CLASS_THERMOSTAT_SETPOINT) of this node.
681+
The command 0x44 (COMMAND_CLASS_THERMOSTAT_FAN_MODE) of this node.
682+
The command 0x45 (COMMAND_CLASS_THERMOSTAT_FAN_STATE) of this node.
683+
Retrieve the list of values to consider as thermostats.
684+
Filter rules are :
685+
686+
command_class = 0x40-45
687+
genre = "User"
688+
readonly = True/False
689+
writeonly = False
690+
691+
:param type: the type of value
692+
:type type: 'All' or PyValueTypes
693+
:return: The list of switches on this node
694+
:rtype: dict()
695+
696+
"""
697+
values = {}
698+
values.update(self.get_values(type=type, class_id=0x40, genre='User', \
699+
readonly=False, writeonly=False))
700+
values.update(self.get_values(type=type, class_id=0x42, genre='User', \
701+
readonly=True, writeonly=False))
702+
values.update(self.get_values(type=type, class_id=0x43, genre='User', \
703+
readonly=False, writeonly=False))
704+
values.update(self.get_values(type=type, class_id=0x44, genre='User', \
705+
readonly=False, writeonly=False))
706+
values.update(self.get_values(type=type, class_id=0x45, genre='User', \
707+
readonly=True, writeonly=False))
708+
return values
709+
710+
def get_thermostat_value(self, value_id):
711+
"""
712+
The command 0x40 (COMMAND_CLASS_THERMOSTAT_MODE) of this node.
713+
The command 0x42 (COMMAND_CLASS_THERMOSTAT_OPERATING_STATE) of this node.
714+
The command 0x43 (COMMAND_CLASS_THERMOSTAT_SETPOINT) of this node.
715+
The command 0x44 (COMMAND_CLASS_THERMOSTAT_FAN_MODE) of this node.
716+
The command 0x45 (COMMAND_CLASS_THERMOSTAT_FAN_STATE) of this node.
717+
718+
:param value_id: The value to retrieve value
719+
:type value_id: int
720+
:return: The state of the thermostats
721+
:rtype: variable
722+
723+
"""
724+
if value_id in self.get_thermostats():
725+
return self.values[value_id].data
726+
return None
727+
728+
def set_thermostat_mode(self, value):
729+
"""
730+
The command 0x40 (COMMAND_CLASS_THERMOSTAT_MODE) of this node.
731+
Set MODE to value (using value).
732+
733+
:param value: The mode : 'Off', 'Heat', 'Cool'
734+
:type value: String
735+
736+
"""
737+
logger.debug(u"set_thermostat_mode value:%s", value)
738+
for v in self.get_thermostats():
739+
if self.values[v].command_class == 0x40 and self.values[v].label == 'Mode':
740+
self.values[v].data = value
741+
return True
742+
return False
743+
744+
def set_thermostat_fan_mode(self, value):
745+
"""
746+
The command 0x44 (COMMAND_CLASS_THERMOSTAT_FAN_MODE) of this node.
747+
Set FAN_MODE to value (using value).
748+
749+
:param value: The mode : 'On Low', 'Auto Low'
750+
:type value: String
751+
752+
"""
753+
logger.debug(u"set_thermostat_fan_mode value:%s", value)
754+
for v in self.get_thermostats():
755+
if self.values[v].command_class == 0x44 and self.values[v].label == 'Fan Mode':
756+
self.values[v].data = value
757+
return True
758+
return False
759+
760+
def set_thermostat_heating(self, value):
761+
"""
762+
The command 0x43 (COMMAND_CLASS_THERMOSTAT_SETPOINT) of this node.
763+
Set Target Heat temperature.
764+
765+
:param value: The Temperature.
766+
:type value: Decimal
767+
768+
"""
769+
logger.debug(u"set_thermostat_heating value:%s", value)
770+
for v in self.get_thermostats():
771+
if self.values[v].command_class == 0x43 and self.values[v].label == 'Heating 1':
772+
self.values[v].data = value
773+
return True
774+
return False
775+
776+
def set_thermostat_cooling(self, value):
777+
"""
778+
The command 0x43 (COMMAND_CLASS_THERMOSTAT_SETPOINT) of this node.
779+
Set MODE to value (using value).
780+
Set Target Cool temperature.
781+
782+
:param value: The Temperature.
783+
:type value: Decimal
784+
785+
"""
786+
logger.debug(u"set_thermostat_cooling value:%s", value)
787+
for v in self.get_thermostats():
788+
if self.values[v].command_class == 0x43 and self.values[v].label == 'Cooling 1':
789+
self.values[v].data = value
790+
return True
791+
return False
792+
793+
def get_thermostat_state(self):
794+
"""
795+
The command 0x42 (COMMAND_CLASS_THERMOSTAT_OPERATING_STATE) of this node.
796+
Get thermostat state.
797+
798+
:param value: None
799+
:rtype value: String
800+
801+
"""
802+
for v in self.get_thermostats():
803+
if self.values[v].command_class == 0x42 and self.values[v].label == 'Operating State':
804+
return self.values[v].data
805+
return None
806+
807+
def get_thermostat_fan_state(self):
808+
"""
809+
The command 0x45 (COMMAND_CLASS_THERMOSTAT_FAN_STATE) of this node.
810+
Get thermostat state.
811+
812+
:param value: None
813+
:rtype value: String
814+
815+
"""
816+
for v in self.get_thermostats():
817+
if self.values[v].command_class == 0x45 and self.values[v].label == 'Fan State':
818+
return self.values[v].data
819+
return None
820+
821+
669822
class ZWaveNodeSecurity(ZWaveNodeInterface):
670823
"""
671824
Represents an interface to Security Commands

‎src-api/openzwave/node.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
from openzwave.group import ZWaveGroup
2828
from openzwave.value import ZWaveValue
2929
from openzwave.command import ZWaveNodeBasic, ZWaveNodeSwitch
30-
from openzwave.command import ZWaveNodeSensor, ZWaveNodeSecurity
30+
from openzwave.command import ZWaveNodeSensor, ZWaveNodeThermostat
31+
from openzwave.command import ZWaveNodeSecurity
3132

3233
# Set default logging handler to avoid "No handler found" warnings.
3334
import logging
@@ -43,7 +44,8 @@ def emit(self, record):
4344

4445
class ZWaveNode(ZWaveObject,
4546
ZWaveNodeBasic, ZWaveNodeSwitch,
46-
ZWaveNodeSensor, ZWaveNodeSecurity):
47+
ZWaveNodeSensor, ZWaveNodeThermostat,
48+
ZWaveNodeSecurity):
4749
"""
4850
Represents a single Node within the Z-Wave Network.
4951

0 commit comments

Comments
 (0)