diff --git a/README.md b/README.md index a4c8311..580392b 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,16 @@ The climate will have 2 modes : ## Configuration -| Key | Type | Required | Description | -| :----------------- | :------ | :------- | :-------------------------------------------------------------------------------------------------------------------------- | -| `platform` | string | yes | Platform name | -| `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) | -| `name` | string | no | Name to use in the frontend. | -| `unique_id` | string | no | An ID that uniquely identifies this cover group. If two climates have the same unique ID, Home Assistant will raise an error. | +| Key | Type | Required | Description | +| :----------------- | :------ | :------- | :------------------------------------------------------------------------------------------------------------------------ | +| `platform` | string | yes | Platform name | +| `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) | +| `name` | string | no | Name to use in the frontend. | +| `unique_id` | string | no | An ID that uniquely identifies this climate. If two climates have the same unique ID, Home Assistant will raise an error. | -The unique id is recommended to allow icon, entity_id or name changes from the UI. +The unique id is recommended to allow icon, entity_id or name changes from the UI. ## Example @@ -69,13 +69,20 @@ climate: sensor: sensor.temperature_living_room ``` -using unique_id (This allow you to edit entity_id, name, icon from the UI) +## Unique ID + +The `unique_id` is used to edit the entity from the GUI. It's automatically generated from heater entity_id. As the `unique_id` must be unique, you can not create 2 entities with the same heater. + +If you want to have 2 climate with the same heater, you must specify the `unique_id` in the config. ```yaml climate: - platform: qubino_wire_pilot heater: light.heater_living_room_dimmer - unique_id: qubino_thermostat + unique_id: qubino_heater_living_room_1 + - platform: qubino_wire_pilot + heater: light.heater_living_room_dimmer + unique_id: qubino_heater_living_room_2 ``` ## Lovelace diff --git a/custom_components/qubino_wire_pilot/climate.py b/custom_components/qubino_wire_pilot/climate.py index b67857f..0c9eeef 100644 --- a/custom_components/qubino_wire_pilot/climate.py +++ b/custom_components/qubino_wire_pilot/climate.py @@ -77,7 +77,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= additional_modes = config.get(CONF_ADDITIONAL_MODES) async_add_entities( - [QubinoWirePilotClimate(unique_id, name, heater_entity_id, sensor_entity_id, additional_modes)] + [QubinoWirePilotClimate( + unique_id, name, heater_entity_id, sensor_entity_id, additional_modes)] ) @@ -86,13 +87,13 @@ class QubinoWirePilotClimate(ClimateEntity, RestoreEntity): def __init__(self, unique_id, name, heater_entity_id, sensor_entity_id, additional_modes): """Initialize the climate device.""" - + self.heater_entity_id = heater_entity_id self.sensor_entity_id = sensor_entity_id self.additional_modes = additional_modes self._cur_temperature = None - - self._attr_unique_id = unique_id + + self._attr_unique_id = unique_id if unique_id else "qubino_wire_pilot_" + heater_entity_id self._attr_name = name async def async_added_to_hass(self): @@ -118,7 +119,8 @@ def _async_startup(event): self.async_schedule_update_ha_state() - self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _async_startup) + self.hass.bus.async_listen_once( + EVENT_HOMEASSISTANT_START, _async_startup) @property def supported_features(self): @@ -195,7 +197,7 @@ async def async_set_preset_mode(self, preset_mode): value = VALUE_COMFORT_1 elif preset_mode == PRESET_COMFORT: value = VALUE_COMFORT - + await self._async_set_heater_value(value) # Modes @@ -252,4 +254,4 @@ async def _async_set_heater_value(self, value): light.ATTR_BRIGHTNESS: value * 255 / 99, } - await self.hass.services.async_call(light.DOMAIN, light.SERVICE_TURN_ON, data) \ No newline at end of file + await self.hass.services.async_call(light.DOMAIN, light.SERVICE_TURN_ON, data) diff --git a/custom_components/qubino_wire_pilot/manifest.json b/custom_components/qubino_wire_pilot/manifest.json index 21de2b2..c4c5d24 100644 --- a/custom_components/qubino_wire_pilot/manifest.json +++ b/custom_components/qubino_wire_pilot/manifest.json @@ -5,6 +5,6 @@ "issue_tracker": "https://github.com/piitaya/home-assitant-qubino_wire_pilot/issues", "requirements": [], "dependencies": [], - "version": "1.2.0", + "version": "2.0.0", "codeowners": ["@piitaya"] }