@@ -28,6 +28,12 @@ async def async_setup_entry(hass, entry, async_add_entities):
2828 for quasar , device , config in hass_utils .incluce_devices (hass , entry )
2929 if device ["type" ] in INCLUDE_TYPES
3030 )
31+ # this should be fixed someday
32+ async_add_entities (
33+ YandexRemoteCarSeat (quasar , device , config )
34+ for quasar , device , config in hass_utils .incluce_devices (hass , entry )
35+ if device ["type" ] == "devices.types.remote_car.seat"
36+ )
3137
3238
3339# HA: auto, cool, dry, fan_only, heat; heat_cool, off
@@ -203,3 +209,35 @@ async def internal_set_hvac_mode(self, value: str) -> bool:
203209 raise e
204210
205211 return False
212+
213+
214+ class YandexRemoteCarSeat (ClimateEntity , YandexEntity ):
215+ _attr_temperature_unit = UnitOfTemperature .CELSIUS
216+ _attr_supported_features = (
217+ ClimateEntityFeature .TURN_ON
218+ | ClimateEntityFeature .TURN_OFF
219+ | ClimateEntityFeature .PRESET_MODE
220+ )
221+ _attr_hvac_modes = [HVACMode .OFF , HVACMode .HEAT ]
222+
223+ def internal_init (self , capabilities : dict , properties : dict ):
224+ # {'instance': 'heating_mode', 'looped': False, 'name': 'режим обогрева', 'random_access': True, 'range': {'max': 3, 'min': 1, 'precision': 1}, 'retrievable': True, 'unit': ''}
225+ if mode := capabilities .get ("heating_mode" ):
226+ modes = range (mode ["range" ]["min" ], mode ["range" ]["max" ] + 1 )
227+ self ._attr_preset_modes = [str (i ) for i in modes ]
228+
229+ def internal_update (self , capabilities : dict , properties : dict ):
230+ if (value := capabilities .get ("on" )) is not None :
231+ self ._attr_hvac_mode = HVACMode .HEAT if value else HVACMode .OFF
232+
233+ if value := capabilities .get ("heating_mode" ):
234+ self ._attr_preset_mode = str (value )
235+
236+ async def async_set_hvac_mode (self , hvac_mode : HVACMode ):
237+ if hvac_mode == HVACMode .OFF :
238+ await self .device_action ("on" , False )
239+ elif hvac_mode == HVACMode .HEAT :
240+ await self .device_action ("on" , True )
241+
242+ async def async_set_preset_mode (self , preset_mode : str ):
243+ await self .device_action ("heating_mode" , int (preset_mode ))
0 commit comments