Zwave Climate: Fan state attribute missing (#25287) (#25573)

Add fan state back in to device state attributes
Change fan state to fan action
This commit is contained in:
jaminh 2019-08-05 05:25:48 -05:00 committed by Pascal Vizeli
parent cecfb2d657
commit 5e00b546eb
4 changed files with 28 additions and 12 deletions

View file

@ -39,7 +39,7 @@ REMOTEC = 0x5254
REMOTEC_ZXT_120 = 0x8377
REMOTEC_ZXT_120_THERMOSTAT = (REMOTEC, REMOTEC_ZXT_120)
ATTR_OPERATING_STATE = "operating_state"
ATTR_FAN_STATE = "fan_state"
ATTR_FAN_ACTION = "fan_action"
# Device is in manufacturer specific mode (e.g. setting the valve manually)
@ -133,7 +133,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
self._preset_mode = None # ha_mode if exists, else zwave_mode
self._current_fan_mode = None
self._fan_modes = None
self._fan_state = None
self._fan_action = None
self._current_swing_mode = None
self._swing_modes = None
self._unit = temp_unit
@ -291,8 +291,8 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
self._hvac_action = HVAC_CURRENT_MAPPINGS.get(str(mode).lower(), mode)
# Fan operating state
if self.values.fan_state:
self._fan_state = self.values.fan_state.data
if self.values.fan_action:
self._fan_action = self.values.fan_action.data
@property
def fan_mode(self):
@ -426,3 +426,11 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
if self._zxt_120 == 1:
if self.values.zxt_120_swing_mode:
self.values.zxt_120_swing_mode.data = swing_mode
@property
def device_state_attributes(self):
"""Return the optional state attributes."""
data = super().device_state_attributes
if self._fan_action:
data[ATTR_FAN_ACTION] = self._fan_action
return data

View file

@ -173,7 +173,7 @@ COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL = 41
COMMAND_CLASS_TARIFF_TBL_CONFIG = 74
COMMAND_CLASS_TARIFF_TBL_MONITOR = 75
COMMAND_CLASS_THERMOSTAT_FAN_MODE = 68
COMMAND_CLASS_THERMOSTAT_FAN_STATE = 69
COMMAND_CLASS_THERMOSTAT_FAN_ACTION = 69
COMMAND_CLASS_THERMOSTAT_MODE = 64
COMMAND_CLASS_THERMOSTAT_OPERATING_STATE = 66
COMMAND_CLASS_THERMOSTAT_SETBACK = 71

View file

@ -78,9 +78,9 @@ DISCOVERY_SCHEMAS = [
],
const.DISC_OPTIONAL: True,
},
"fan_state": {
"fan_action": {
const.DISC_COMMAND_CLASS: [
const.COMMAND_CLASS_THERMOSTAT_FAN_STATE
const.COMMAND_CLASS_THERMOSTAT_FAN_ACTION
],
const.DISC_OPTIONAL: True,
},

View file

@ -43,7 +43,7 @@ def device(hass, mock_openzwave):
),
fan_mode=MockValue(data="test2", data_items=[3, 4, 5], node=node),
operating_state=MockValue(data=CURRENT_HVAC_HEAT, node=node),
fan_state=MockValue(data=7, node=node),
fan_action=MockValue(data=7, node=node),
)
device = climate.get_device(hass, node=node, values=values, node_config={})
@ -70,7 +70,7 @@ def device_zxt_120(hass, mock_openzwave):
),
fan_mode=MockValue(data="test2", data_items=[3, 4, 5], node=node),
operating_state=MockValue(data=CURRENT_HVAC_HEAT, node=node),
fan_state=MockValue(data=7, node=node),
fan_action=MockValue(data=7, node=node),
zxt_120_swing_mode=MockValue(data="test3", data_items=[6, 7, 8], node=node),
)
device = climate.get_device(hass, node=node, values=values, node_config={})
@ -92,7 +92,7 @@ def device_mapping(hass, mock_openzwave):
),
fan_mode=MockValue(data="test2", data_items=[3, 4, 5], node=node),
operating_state=MockValue(data="heating", node=node),
fan_state=MockValue(data=7, node=node),
fan_action=MockValue(data=7, node=node),
)
device = climate.get_device(hass, node=node, values=values, node_config={})
@ -113,7 +113,7 @@ def device_unknown(hass, mock_openzwave):
),
fan_mode=MockValue(data="test2", data_items=[3, 4, 5], node=node),
operating_state=MockValue(data="test4", node=node),
fan_state=MockValue(data=7, node=node),
fan_action=MockValue(data=7, node=node),
)
device = climate.get_device(hass, node=node, values=values, node_config={})
@ -140,7 +140,7 @@ def device_heat_cool(hass, mock_openzwave):
),
fan_mode=MockValue(data="test2", data_items=[3, 4, 5], node=node),
operating_state=MockValue(data="test4", node=node),
fan_state=MockValue(data=7, node=node),
fan_action=MockValue(data=7, node=node),
)
device = climate.get_device(hass, node=node, values=values, node_config={})
@ -442,3 +442,11 @@ def test_hvac_action_value_changed_unknown(device_unknown):
device.values.operating_state.data = "another_hvac_action"
value_changed(device.values.operating_state)
assert device.hvac_action == "another_hvac_action"
def test_fan_action_value_changed(device):
"""Test values changed for climate device."""
assert device.device_state_attributes[climate.ATTR_FAN_ACTION] == 7
device.values.fan_action.data = 9
value_changed(device.values.fan_action)
assert device.device_state_attributes[climate.ATTR_FAN_ACTION] == 9