|
30 | 30 | from .const import CONF_ALL_DAYS, DOMAIN |
31 | 31 | from .coordinator import CometBlueConfigEntry, CometBlueDataUpdateCoordinator |
32 | 32 | from .entity import CometBlueBluetoothEntity |
33 | | -from .utils import ( |
34 | | - SERVICE_DATETIME_SCHEMA, |
35 | | - SERVICE_HOLIDAY_SCHEMA, |
36 | | - SERVICE_SCHEDULE_SCHEMA, |
37 | | -) |
| 33 | +from .utils import SERVICE_HOLIDAY_SCHEMA, SERVICE_SCHEDULE_SCHEMA |
38 | 34 |
|
39 | 35 | CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) |
40 | 36 | PLATFORMS: list[Platform] = [ |
| 37 | + Platform.BUTTON, |
41 | 38 | Platform.CLIMATE, |
42 | 39 | Platform.NUMBER, |
43 | 40 | Platform.SENSOR, |
@@ -71,27 +68,33 @@ async def _async_migrate_entries( |
71 | 68 |
|
72 | 69 | @callback |
73 | 70 | def update_unique_id(entry: er.RegistryEntry) -> dict[str, str] | None: |
| 71 | + new_unique_id = None |
74 | 72 | if entry.domain == "climate" and entry.unique_id.endswith("-climate"): |
75 | 73 | new_unique_id = entry.unique_id.replace("-climate", "") |
| 74 | + elif entry.domain == "number" and entry.unique_id.endswith("-target_temp_low"): |
| 75 | + new_unique_id = entry.unique_id.replace("-target_temp_low", "-eco_setpoint") |
| 76 | + elif entry.domain == "number" and entry.unique_id.endswith("-target_temp_high"): |
| 77 | + new_unique_id = entry.unique_id.replace("-target_temp_high", "-comfort_setpoint") |
| 78 | + else: |
| 79 | + return None |
| 80 | + LOGGER.debug( |
| 81 | + "Migrating entity '%s' unique_id from '%s' to '%s'", |
| 82 | + entry.entity_id, |
| 83 | + entry.unique_id, |
| 84 | + new_unique_id, |
| 85 | + ) |
| 86 | + if existing_entity_id := entity_registry.async_get_entity_id( |
| 87 | + entry.domain, entry.platform, new_unique_id |
| 88 | + ): |
76 | 89 | LOGGER.debug( |
77 | | - "Migrating entity '%s' unique_id from '%s' to '%s'", |
78 | | - entry.entity_id, |
79 | | - entry.unique_id, |
| 90 | + "Cannot migrate to unique_id '%s', already exists for '%s'", |
80 | 91 | new_unique_id, |
| 92 | + existing_entity_id, |
81 | 93 | ) |
82 | | - if existing_entity_id := entity_registry.async_get_entity_id( |
83 | | - entry.domain, entry.platform, new_unique_id |
84 | | - ): |
85 | | - LOGGER.debug( |
86 | | - "Cannot migrate to unique_id '%s', already exists for '%s'", |
87 | | - new_unique_id, |
88 | | - existing_entity_id, |
89 | | - ) |
90 | | - return None |
91 | | - return { |
92 | | - "new_unique_id": new_unique_id, |
93 | | - } |
94 | | - return None |
| 94 | + return None |
| 95 | + return { |
| 96 | + "new_unique_id": new_unique_id, |
| 97 | + } |
95 | 98 |
|
96 | 99 | await er.async_migrate_entries(hass, config_entry.entry_id, update_unique_id) |
97 | 100 |
|
@@ -160,16 +163,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: CometBlueConfigEntry) -> |
160 | 163 | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: |
161 | 164 | """Set up Eurotronic Comet Blue entity services.""" |
162 | 165 |
|
163 | | - async def set_datetime( |
164 | | - entity: CometBlueBluetoothEntity, service_call: ServiceCall |
165 | | - ) -> None: |
166 | | - """Service call to update the datetime on the device.""" |
167 | | - target_datetime = service_call.data.get("datetime") or datetime.now() |
168 | | - await entity.coordinator.send_command( |
169 | | - entity.coordinator.device.set_datetime_async, |
170 | | - {"date": target_datetime}, |
171 | | - ) |
172 | | - |
173 | 166 | async def get_schedule( |
174 | 167 | entity: CometBlueBluetoothEntity, service_call: ServiceCall |
175 | 168 | ) -> ServiceResponse: |
@@ -236,15 +229,6 @@ async def set_holiday( |
236 | 229 | }, |
237 | 230 | ) |
238 | 231 |
|
239 | | - service.async_register_platform_entity_service( |
240 | | - hass, |
241 | | - DOMAIN, |
242 | | - "set_datetime", |
243 | | - entity_domain="climate", |
244 | | - schema=cv.make_entity_service_schema(SERVICE_DATETIME_SCHEMA), |
245 | | - supports_response=SupportsResponse.NONE, |
246 | | - func=set_datetime, |
247 | | - ) |
248 | 232 | service.async_register_platform_entity_service( |
249 | 233 | hass, |
250 | 234 | DOMAIN, |
|
0 commit comments