Skip to content

Commit

Permalink
Adding none type for equipment type, fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
craigmaloney committed Nov 4, 2020
1 parent 33f7450 commit ab09cd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion tests/test_equipment_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def test_has_heating():
'furnace_or_boiler', # Non heat pump heating (gas or oil furnace, electric resistance)
'heat_pump_electric_backup', # Heat pump with electric resistance heat (strip heat)
'heat_pump_no_electric_backup', # Heat pump without electric resistance heat
'electric_resistance', # Electric Resistance (Line-voltage thermostat)
]:
assert(has_heating(i) is True)
for i in [
'heat_pump_dual_fuel', # Dual fuel heat pump (e.g. gas or oil fired)
'electric_resistance', # Electric Resistance (Line-voltage thermostat)
'other', # Multi-zone, ?
'none', # None
]:
Expand Down Expand Up @@ -74,6 +74,8 @@ def test_has_two_stage_cooling():
assert(has_two_stage_cooling('single_speed') is False)
assert(has_two_stage_cooling('modulating') is False)
assert(has_two_stage_cooling(None) is False)
assert(has_two_stage_cooling('none') is False)
assert(has_two_stage_cooling('') is False)
assert(validate_cool_stage('two_speed') is True)
assert(validate_cool_stage('ten_speed') is False)

Expand All @@ -83,6 +85,8 @@ def test_has_two_stage_heating():
assert(has_two_stage_heating('single_stage') is False)
assert(has_two_stage_heating('modulating') is False)
assert(has_two_stage_heating(None) is False)
assert(has_two_stage_heating('none') is False)
assert(has_two_stage_heating('') is False)
assert(validate_heat_stage('two_stage') is True)
assert(validate_heat_stage('2_stage') is False)

Expand Down
10 changes: 6 additions & 4 deletions thermostat/equipment_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'two_stage', # Dual capacity heater or dual stage compressor
'modulating', # Modulating or variable capacity unit
'variable_speed', # Modulating or variable capacity unit
'none', # No central heating system
]

COOL_TYPE = [
Expand All @@ -32,6 +33,7 @@
'two_stage', # Dual stage compressor (synonym)
'modulating', # Modulating or variable capacity compressor
'variable_speed', # Modulating or variable capacity unit
'none', # No central cooling system
]

#: This mapping is for old scripts that need to refer to the old mapping, but want to use the new functionality.
Expand Down Expand Up @@ -258,28 +260,28 @@ def is_line_voltage(heat_type):
def validate_heat_type(heat_type):
if heat_type is None or heat_type == '' or heat_type in HEAT_TYPE:
return True
logging.warn("Heating type {heat_type} is not a recognized heating type.".format(heat_type=heat_type))
logging.warning("Heating type {heat_type} is not a recognized heating type.".format(heat_type=heat_type))
return False


def validate_cool_type(cool_type):
if cool_type is None or cool_type == '' or cool_type in COOL_TYPE:
return True
logging.warn("Cooling type {cool_type} is not a recognized cooling type.".format(cool_type=cool_type))
logging.warning("Cooling type {cool_type} is not a recognized cooling type.".format(cool_type=cool_type))
return False


def validate_heat_stage(heat_stage):
if heat_stage is None or heat_stage == '' or heat_stage in HEAT_STAGE:
return True
logging.warn("Heating stage {heat_stage} is not a recognized heating stage.".format(heat_stage=heat_stage))
logging.warning("Heating stage {heat_stage} is not a recognized heating stage.".format(heat_stage=heat_stage))
return False


def validate_cool_stage(cool_stage):
if cool_stage is None or cool_stage == '' or cool_stage in COOL_STAGE:
return True
logging.warn("Cooling stage {cool_stage} is not a recognized cooling stage.".format(cool_stage=cool_stage))
logging.warning("Cooling stage {cool_stage} is not a recognized cooling stage.".format(cool_stage=cool_stage))
return False


Expand Down

0 comments on commit ab09cd5

Please sign in to comment.