Skip to content

Commit

Permalink
add comfort -1 and comfort -2 modes support (#1)
Browse files Browse the repository at this point in the history
* add 6 order support

* add 6 order option to readme

* rename new parameter
  • Loading branch information
piitaya authored Mar 29, 2021
1 parent 0034e6e commit 6443a3e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,38 @@ Home Assistant Component for Qubino Wire Pilot
The Qubino ZMNHJD1 is not recognized as a thermostat in Home Assistant but as a light.
The light percentage is mapped to a mode.

| Value | Min | Max
:--- | :--- | :---
| Off | 0% | 10%
| Frost protection | 11% | 20%
| Eco | 21% | 30%
| Comfort -2 | 31% | 40%
| Comfort -1 | 41% | 50%
| Comfort | 51% | 100%
| Value | Min | Max |
| :--------------- | :-- | :--- |
| Off | 0% | 10% |
| Frost protection | 11% | 20% |
| Eco | 21% | 30% |
| Comfort -2 | 31% | 40% |
| Comfort -1 | 41% | 50% |
| Comfort | 51% | 100% |

This component create a `climate` entity using the `light` entity.

The climate will have 2 modes :

- `heat` - splitted into 3 presets :
- `comfort` - mapped qubino "Comfort" mode)
- `eco` - mapped qubino "Eco" mode)
- `away` - mapped qubino "Frost protection" mode)
- `off` - mapped qubino "Off" mode) :
- `heat` - splitted into 3 or 5 presets :
- `comfort` - mapped qubino "Comfort" mode
- `comfort-1` - mapped qubino "Comfort -1" mode (optional)
- `comfort-2` - mapped qubino "Comfort -2" mode (optional)
- `eco` - mapped qubino "Eco" mode
- `away` - mapped qubino "Frost protection" mode
- `off` - mapped qubino "Off" mode :

:warning: "Comfort -1" and "Comfort -2" are not supported by this component.
:warning: "Comfort -1" and "Comfort -2" are not available by default because home assistant doesn't have comfort-1 and comfort-2 preset. If you want to support these modes, add `additional_modes: true` in your configuration.

## Configuration

| Key | Type | Required | Description
:--- | :--- | :--- | :---
| `platform` | string | yes | Platform name
| `name` | string | yes | Name of the entity
| `heater` | string | yes | Light entity
| `sensor` | string | no | Temperature sensor (for display)
| Key | Type | Required | Description |
| :----------------- | :------ | :------- | :----------------------------------------------------- |
| `platform` | string | yes | Platform name |
| `name` | string | yes | Name of the entity |
| `heater` | string | yes | Light entity |
| `sensor` | string | no | Temperature sensor (for display) |
| `additional_modes` | boolean | no | 6-order support (add Comfort -1 and Comfort -2 preset) |

## Example

Expand All @@ -46,7 +49,17 @@ climate:
heater: light.heater_living_room_dimmer
```
or with optional sensor
with 6 order
```yaml
climate:
- platform: qubino_wire_pilot
name: thermostat_living_room
heater: light.heater_living_room_dimmer
additional_modes: true
```
with optional sensor
```yaml
climate:
Expand Down
30 changes: 24 additions & 6 deletions custom_components/qubino_wire_pilot/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@

CONF_HEATER = "heater"
CONF_SENSOR = "sensor"
CONF_ADDITIONAL_MODES = "additional_modes"
CONF_NAME = "name"

PRESET_COMFORT_1 = "comfort-1"
PRESET_COMFORT_2 = "comfort-2"

VALUE_OFF = 10
VALUE_FROST = 20
VALUE_ECO = 30
Expand All @@ -58,6 +62,7 @@
vol.Required(CONF_HEATER): cv.entity_id,
vol.Optional(CONF_SENSOR): cv.entity_id,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_ADDITIONAL_MODES, default=False): cv.boolean,
}
)

Expand All @@ -69,20 +74,22 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
name = config.get(CONF_NAME)
heater_entity_id = config.get(CONF_HEATER)
sensor_entity_id = config.get(CONF_SENSOR)

additional_modes = config.get(CONF_ADDITIONAL_MODES)

async_add_entities(
[QubinoWirePilotClimate(name, heater_entity_id, sensor_entity_id)]
[QubinoWirePilotClimate(name, heater_entity_id, sensor_entity_id, additional_modes)]
)


class QubinoWirePilotClimate(ClimateEntity, RestoreEntity):
"""Representation of a Qubino Wire Pilot device."""

def __init__(self, name, heater_entity_id, sensor_entity_id):
def __init__(self, name, heater_entity_id, sensor_entity_id, additional_modes):
"""Initialize the climate device."""
self._name = name
self.heater_entity_id = heater_entity_id
self.sensor_entity_id = sensor_entity_id
self.additional_modes = additional_modes
self._cur_temperature = None

async def async_added_to_hass(self):
Expand Down Expand Up @@ -153,7 +160,10 @@ def heater_value(self):
@property
def preset_modes(self):
"""List of available preset modes."""
return [PRESET_COMFORT, PRESET_ECO, PRESET_AWAY]
if self.additional_modes:
return [PRESET_COMFORT, PRESET_COMFORT_1, PRESET_COMFORT_2, PRESET_ECO, PRESET_AWAY]
else:
return [PRESET_COMFORT, PRESET_ECO, PRESET_AWAY]

@property
def preset_mode(self):
Expand All @@ -167,6 +177,10 @@ def preset_mode(self):
return PRESET_AWAY
elif value <= VALUE_ECO:
return PRESET_ECO
elif value <= VALUE_COMFORT_2 and self.additional_modes:
return PRESET_COMFORT_2
elif value <= VALUE_COMFORT_1 and self.additional_modes:
return PRESET_COMFORT_1
else:
return PRESET_COMFORT

Expand All @@ -175,11 +189,15 @@ async def async_set_preset_mode(self, preset_mode):

if preset_mode == PRESET_AWAY:
value = VALUE_FROST
if preset_mode == PRESET_ECO:
elif preset_mode == PRESET_ECO:
value = VALUE_ECO
elif preset_mode == PRESET_COMFORT_2 and self.additional_modes:
value = VALUE_COMFORT_2
elif preset_mode == PRESET_COMFORT_1 and self.additional_modes:
value = VALUE_COMFORT_1
elif preset_mode == PRESET_COMFORT:
value = VALUE_COMFORT

await self._async_set_heater_value(value)

# Modes
Expand Down

0 comments on commit 6443a3e

Please sign in to comment.