Skip to content

Commit

Permalink
Add some sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Sep 29, 2023
1 parent f02ec78 commit 6516f87
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 26 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,10 @@ For every device exists a button under diagnostics which can be used to log all
| Energy Label | `lightning-bolt-circle` | `sensor` | `startProgram.energyLabel` |
| Program | | `select` | `startProgram.program` |
| Steam Type | `weather-dust` | `sensor` | `steamType` |
| Sterilization | `clock-start` | `switch` | `startProgram.sterilizationStatus` |
| Sterilization | `lotion-plus` | `switch` | `startProgram.sterilizationStatus` |
| Suggested Load | `weight-kilogram` | `sensor` | `startProgram.suggestedLoadD` |
| Temperature level | `thermometer` | `number` | `startProgram.tempLevel` |
| Tumbling | `refresh-circle` | `switch` | `startProgram.tumblingStatus` |
#### Sensors
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
Expand Down Expand Up @@ -426,14 +427,17 @@ For every device exists a button under diagnostics which can be used to log all
#### Controls
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Auto Dose Detergent | `cup` | `switch` | `autoDetergentStatus` |
| Auto Dose Softener | `teddy-bear` | `switch` | `autoSoftenerStatus` |
| Pause Washer Dryer | `pause` | `switch` | `pauseProgram` / `resumeProgram` |
| Washer Dryer | `washing-machine` | `switch` | `startProgram` / `stopProgram` |
| Water hard | `water` | `number` | `settings.waterHard` |
#### Configs
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Acqua Plus | `water-plus` | `switch` | `startProgram.acquaplus` |
| Anti-Crease | `iron` | `switch` | `startProgram.antiCreaseTime` |
| Anti-Crease | `iron` | `switch` | `startProgram.anticrease` |
| Anti-Crease | `iron` | `switch` | `startProgram.antiCreaseTime` |
| Auto Dose Detergent | `cup` | `switch` | `startProgram.autoDetergentStatus` |
| Auto Dose Softener | `teddy-bear` | `switch` | `startProgram.autoSoftenerStatus` |
| Delay Status | `timer-check` | `switch` | `startProgram.delayStatus` |
Expand All @@ -452,19 +456,21 @@ For every device exists a button under diagnostics which can be used to log all
| Liquid Detergent Dose | `cup-water` | `sensor` | `startProgram.liquidDetergentDose` |
| Main Wash Time | `clock-start` | `number` | `startProgram.mainWashTime` |
| Powder Detergent Dose | `cup` | `sensor` | `startProgram.powderDetergentDose` |
| Prewash | `tshirt-crew` | `switch` | `startProgram.prewash` |
| Program | | `select` | `startProgram.program` |
| Remaining Time | `timer` | `sensor` | `startProgram.remainingTime` |
| Rinse Iterations | `rotate-right` | `number` | `startProgram.rinseIterations` |
| Soak Prewash Selection | `tshirt-crew` | `switch` | `startProgram.haier_SoakPrewashSelection` |
| Spin speed | `numeric` | `select` | `startProgram.spinSpeed` |
| Steam Type | `weather-dust` | `sensor` | `steamType` |
| Steam level | `weather-dust` | `select` | `startProgram.steamLevel` |
| Sterilization | `clock-start` | `switch` | `startProgram.sterilizationStatus` |
| Sterilization | `lotion-plus` | `switch` | `startProgram.sterilizationStatus` |
| Suggested Load | `weight-kilogram` | `sensor` | `startProgram.suggestedLoadW` |
| Suggested Load | `weight-kilogram` | `sensor` | `startProgram.suggestedLoadD` |
| Suggested weight | `weight-kilogram` | `sensor` | `startProgram.weight` |
| Temperature | `thermometer` | `select` | `startProgram.temp` |
| Temperature level | `thermometer` | `number` | `startProgram.tempLevel` |
| Tumbling | `refresh-circle` | `switch` | `startProgram.tumblingStatus` |
| Water hard | `water` | `number` | `startProgram.waterHard` |
| lang | | `number` | `startProgram.lang` |
#### Sensors
Expand Down Expand Up @@ -502,12 +508,16 @@ For every device exists a button under diagnostics which can be used to log all
#### Controls
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Auto Dose Detergent | `cup` | `switch` | `autoDetergentStatus` |
| Auto Dose Softener | `teddy-bear` | `switch` | `autoSoftenerStatus` |
| Pause Washing Machine | `pause` | `switch` | `pauseProgram` / `resumeProgram` |
| Washing Machine | `washing-machine` | `switch` | `startProgram` / `stopProgram` |
| Water hard | `water` | `number` | `settings.waterHard` |
#### Configs
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Acqua Plus | `water-plus` | `switch` | `startProgram.acquaplus` |
| Anti-Crease | `iron` | `switch` | `startProgram.anticrease` |
| Auto Dose Detergent | `cup` | `switch` | `startProgram.autoDetergentStatus` |
| Auto Dose Softener | `teddy-bear` | `switch` | `startProgram.autoSoftenerStatus` |
| Delay Status | `timer-check` | `switch` | `startProgram.delayStatus` |
Expand All @@ -523,6 +533,7 @@ For every device exists a button under diagnostics which can be used to log all
| Liquid Detergent Dose | `cup-water` | `sensor` | `startProgram.liquidDetergentDose` |
| Main Wash Time | `clock-start` | `number` | `startProgram.mainWashTime` |
| Powder Detergent Dose | `cup` | `sensor` | `startProgram.powderDetergentDose` |
| Prewash | `tshirt-crew` | `switch` | `startProgram.prewash` |
| Program | | `select` | `startProgram.program` |
| Remaining Time | `timer` | `sensor` | `startProgram.remainingTime` |
| Rinse Iterations | `rotate-right` | `number` | `startProgram.rinseIterations` |
Expand Down
10 changes: 8 additions & 2 deletions custom_components/hon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,23 @@ def preset_mode(self) -> str | None:

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set the new preset mode."""
command = "stopProgram" if preset_mode == "no_mode" else "startProgram"
if preset_mode == "no_mode" and HVACMode.OFF in self.hvac_modes:
command = "stopProgram"
elif preset_mode == "no_mode":
command = "settings"
self._device.commands["settings"].reset()
else:
command = "startProgram"
if program := self._device.settings.get(f"{command}.program"):
program.value = preset_mode
zone = self._device.settings.get(f"{command}.zone")
if zone and isinstance(self.entity_description.name, str):
zone.value = self.entity_description.name.lower()
self._device.sync_command(command, "settings")
self._set_temperature_bound()
self._attr_preset_mode = preset_mode
await self.coordinator.async_refresh()
await self._device.commands[command].send()
self._attr_preset_mode = preset_mode
self.async_write_ha_state()

def _set_temperature_bound(self) -> None:
Expand Down
6 changes: 6 additions & 0 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class HonNumberEntityDescription(NumberEntityDescription):
icon="mdi:water",
translation_key="water_hard",
),
HonNumberEntityDescription(
key="settings.waterHard",
name="Water hard",
icon="mdi:water",
translation_key="water_hard",
),
HonConfigNumberEntityDescription(
key="startProgram.lang",
name="lang",
Expand Down
37 changes: 32 additions & 5 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class HonConfigSwitchEntityDescription(SwitchEntityDescription):
icon="mdi:tshirt-crew",
translation_key="prewash",
),
HonConfigSwitchEntityDescription(
key="startProgram.prewash",
name="Prewash",
icon="mdi:tshirt-crew",
translation_key="prewash",
),
HonConfigSwitchEntityDescription(
key="startProgram.permanentPressStatus",
name="Keep Fresh",
Expand All @@ -81,6 +87,18 @@ class HonConfigSwitchEntityDescription(SwitchEntityDescription):
icon="mdi:cup",
translation_key="auto_dose_detergent",
),
HonSwitchEntityDescription(
key="autoSoftenerStatus",
name="Auto Dose Softener",
icon="mdi:teddy-bear",
translation_key="auto_dose_softener",
),
HonSwitchEntityDescription(
key="autoDetergentStatus",
name="Auto Dose Detergent",
icon="mdi:cup",
translation_key="auto_dose_detergent",
),
HonConfigSwitchEntityDescription(
key="startProgram.acquaplus",
name="Acqua Plus",
Expand Down Expand Up @@ -117,6 +135,12 @@ class HonConfigSwitchEntityDescription(SwitchEntityDescription):
icon="mdi:lotion-plus",
translation_key="hygiene",
),
HonConfigSwitchEntityDescription(
key="startProgram.anticrease",
name="Anti-Crease",
icon="mdi:iron",
translation_key="anti_crease",
),
),
"TD": (
HonControlSwitchEntityDescription(
Expand All @@ -138,7 +162,13 @@ class HonConfigSwitchEntityDescription(SwitchEntityDescription):
HonConfigSwitchEntityDescription(
key="startProgram.sterilizationStatus",
name="Sterilization",
icon="mdi:clock-start",
icon="mdi:lotion-plus",
),
HonConfigSwitchEntityDescription(
key="startProgram.tumblingStatus",
name="Tumbling",
icon="mdi:refresh-circle",
translation_key="keep_fresh",
),
HonConfigSwitchEntityDescription(
key="startProgram.antiCreaseTime",
Expand Down Expand Up @@ -370,10 +400,7 @@ async def async_setup_entry(
continue
entity = HonControlSwitchEntity(hass, entry, device, description)
elif isinstance(description, HonSwitchEntityDescription):
if (
f"settings.{description.key}" not in device.available_settings
or device.get(description.key) is None
):
if f"settings.{description.key}" not in device.available_settings:
continue
entity = HonSwitchEntity(hass, entry, device, description)
else:
Expand Down
Loading

0 comments on commit 6516f87

Please sign in to comment.