mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix SmartThings Samsung Air Conditioner Support (#23706)
* Bump pysmartthings to 0.6.8 * Fix AC climate device * Fix stale comment
This commit is contained in:
parent
d8a219fe0e
commit
074142400a
@ -39,19 +39,19 @@ AC_MODE_TO_STATE = {
|
|||||||
'auto': STATE_AUTO,
|
'auto': STATE_AUTO,
|
||||||
'cool': STATE_COOL,
|
'cool': STATE_COOL,
|
||||||
'dry': STATE_DRY,
|
'dry': STATE_DRY,
|
||||||
|
'coolClean': STATE_COOL,
|
||||||
|
'dryClean': STATE_DRY,
|
||||||
'heat': STATE_HEAT,
|
'heat': STATE_HEAT,
|
||||||
|
'heatClean': STATE_HEAT,
|
||||||
'fanOnly': STATE_FAN_ONLY
|
'fanOnly': STATE_FAN_ONLY
|
||||||
}
|
}
|
||||||
STATE_TO_AC_MODE = {v: k for k, v in AC_MODE_TO_STATE.items()}
|
STATE_TO_AC_MODE = {
|
||||||
|
STATE_AUTO: 'auto',
|
||||||
SPEED_TO_FAN_MODE = {
|
STATE_COOL: 'cool',
|
||||||
0: 'auto',
|
STATE_DRY: 'dry',
|
||||||
1: 'low',
|
STATE_HEAT: 'heat',
|
||||||
2: 'medium',
|
STATE_FAN_ONLY: 'fanOnly'
|
||||||
3: 'high',
|
|
||||||
4: 'turbo'
|
|
||||||
}
|
}
|
||||||
FAN_MODE_TO_SPEED = {v: k for k, v in SPEED_TO_FAN_MODE.items()}
|
|
||||||
|
|
||||||
UNIT_MAP = {
|
UNIT_MAP = {
|
||||||
'C': TEMP_CELSIUS,
|
'C': TEMP_CELSIUS,
|
||||||
@ -73,7 +73,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
ac_capabilities = [
|
ac_capabilities = [
|
||||||
Capability.air_conditioner_mode,
|
Capability.air_conditioner_mode,
|
||||||
Capability.fan_speed,
|
Capability.air_conditioner_fan_mode,
|
||||||
Capability.switch,
|
Capability.switch,
|
||||||
Capability.temperature_measurement,
|
Capability.temperature_measurement,
|
||||||
Capability.thermostat_cooling_setpoint]
|
Capability.thermostat_cooling_setpoint]
|
||||||
@ -98,7 +98,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
|
|||||||
supported = [
|
supported = [
|
||||||
Capability.air_conditioner_mode,
|
Capability.air_conditioner_mode,
|
||||||
Capability.demand_response_load_control,
|
Capability.demand_response_load_control,
|
||||||
Capability.fan_speed,
|
Capability.air_conditioner_fan_mode,
|
||||||
Capability.power_consumption_report,
|
Capability.power_consumption_report,
|
||||||
Capability.relative_humidity_measurement,
|
Capability.relative_humidity_measurement,
|
||||||
Capability.switch,
|
Capability.switch,
|
||||||
@ -124,7 +124,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
|
|||||||
# Or must have all of these A/C capabilities
|
# Or must have all of these A/C capabilities
|
||||||
ac_capabilities = [
|
ac_capabilities = [
|
||||||
Capability.air_conditioner_mode,
|
Capability.air_conditioner_mode,
|
||||||
Capability.fan_speed,
|
Capability.air_conditioner_fan_mode,
|
||||||
Capability.switch,
|
Capability.switch,
|
||||||
Capability.temperature_measurement,
|
Capability.temperature_measurement,
|
||||||
Capability.thermostat_cooling_setpoint]
|
Capability.thermostat_cooling_setpoint]
|
||||||
@ -309,10 +309,14 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateDevice):
|
|||||||
class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
||||||
"""Define a SmartThings Air Conditioner."""
|
"""Define a SmartThings Air Conditioner."""
|
||||||
|
|
||||||
|
def __init__(self, device):
|
||||||
|
"""Init the class."""
|
||||||
|
super().__init__(device)
|
||||||
|
self._operations = None
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode):
|
async def async_set_fan_mode(self, fan_mode):
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
await self._device.set_fan_speed(
|
await self._device.set_fan_mode(fan_mode, set_status=True)
|
||||||
FAN_MODE_TO_SPEED[fan_mode], set_status=True)
|
|
||||||
# State is set optimistically in the command above, therefore update
|
# State is set optimistically in the command above, therefore update
|
||||||
# the entity state ahead of receiving the confirming push updates
|
# the entity state ahead of receiving the confirming push updates
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
@ -354,10 +358,23 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
|||||||
# the entity state ahead of receiving the confirming push updates
|
# the entity state ahead of receiving the confirming push updates
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
|
async def async_update(self):
|
||||||
|
"""Update the calculated fields of the AC."""
|
||||||
|
operations = set()
|
||||||
|
for mode in self._device.status.supported_ac_modes:
|
||||||
|
state = AC_MODE_TO_STATE.get(mode)
|
||||||
|
if state is not None:
|
||||||
|
operations.add(state)
|
||||||
|
else:
|
||||||
|
_LOGGER.debug('Device %s (%s) returned an invalid supported '
|
||||||
|
'AC mode: %s', self._device.label,
|
||||||
|
self._device.device_id, mode)
|
||||||
|
self._operations = operations
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_fan_mode(self):
|
def current_fan_mode(self):
|
||||||
"""Return the fan setting."""
|
"""Return the fan setting."""
|
||||||
return SPEED_TO_FAN_MODE.get(self._device.status.fan_speed)
|
return self._device.status.fan_mode
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_operation(self):
|
def current_operation(self):
|
||||||
@ -397,7 +414,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
"""Return the list of available fan modes."""
|
"""Return the list of available fan modes."""
|
||||||
return list(FAN_MODE_TO_SPEED)
|
return self._device.status.supported_ac_fan_modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
@ -407,7 +424,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def operation_list(self):
|
def operation_list(self):
|
||||||
"""Return the list of available operation modes."""
|
"""Return the list of available operation modes."""
|
||||||
return list(STATE_TO_AC_MODE)
|
return self._operations
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"documentation": "https://www.home-assistant.io/components/smartthings",
|
"documentation": "https://www.home-assistant.io/components/smartthings",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pysmartapp==0.3.2",
|
"pysmartapp==0.3.2",
|
||||||
"pysmartthings==0.6.7"
|
"pysmartthings==0.6.8"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"webhook"
|
"webhook"
|
||||||
|
@ -1294,7 +1294,7 @@ pysma==0.3.1
|
|||||||
pysmartapp==0.3.2
|
pysmartapp==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartthings==0.6.7
|
pysmartthings==0.6.8
|
||||||
|
|
||||||
# homeassistant.components.snmp
|
# homeassistant.components.snmp
|
||||||
pysnmp==4.4.9
|
pysnmp==4.4.9
|
||||||
|
@ -261,7 +261,7 @@ pyqwikswitch==0.93
|
|||||||
pysmartapp==0.3.2
|
pysmartapp==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.smartthings
|
# homeassistant.components.smartthings
|
||||||
pysmartthings==0.6.7
|
pysmartthings==0.6.8
|
||||||
|
|
||||||
# homeassistant.components.sonos
|
# homeassistant.components.sonos
|
||||||
pysonos==0.0.12
|
pysonos==0.0.12
|
||||||
|
@ -124,20 +124,24 @@ def air_conditioner_fixture(device_factory):
|
|||||||
capabilities=[
|
capabilities=[
|
||||||
Capability.air_conditioner_mode,
|
Capability.air_conditioner_mode,
|
||||||
Capability.demand_response_load_control,
|
Capability.demand_response_load_control,
|
||||||
Capability.fan_speed,
|
Capability.air_conditioner_fan_mode,
|
||||||
Capability.power_consumption_report,
|
Capability.power_consumption_report,
|
||||||
Capability.switch,
|
Capability.switch,
|
||||||
Capability.temperature_measurement,
|
Capability.temperature_measurement,
|
||||||
Capability.thermostat_cooling_setpoint],
|
Capability.thermostat_cooling_setpoint],
|
||||||
status={
|
status={
|
||||||
Attribute.air_conditioner_mode: 'auto',
|
Attribute.air_conditioner_mode: 'auto',
|
||||||
|
Attribute.supported_ac_modes:
|
||||||
|
["cool", "dry", "wind", "auto", "heat", "fanOnly"],
|
||||||
Attribute.drlc_status: {
|
Attribute.drlc_status: {
|
||||||
"duration": 0,
|
"duration": 0,
|
||||||
"drlcLevel": -1,
|
"drlcLevel": -1,
|
||||||
"start": "1970-01-01T00:00:00Z",
|
"start": "1970-01-01T00:00:00Z",
|
||||||
"override": False
|
"override": False
|
||||||
},
|
},
|
||||||
Attribute.fan_speed: 2,
|
Attribute.fan_mode: 'medium',
|
||||||
|
Attribute.supported_ac_fan_modes:
|
||||||
|
["auto", "low", "medium", "high", "turbo"],
|
||||||
Attribute.power_consumption: {
|
Attribute.power_consumption: {
|
||||||
"start": "2019-02-24T21:03:04Z",
|
"start": "2019-02-24T21:03:04Z",
|
||||||
"power": 0,
|
"power": 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user