1717 SUPPORT_TARGET_TEMPERATURE ,
1818)
1919from homeassistant .const import ATTR_TEMPERATURE , TEMP_CELSIUS
20- from . import DOMAIN , CONF_COOL_TEMP , CONF_HEAT_TEMP
20+ from . import DOMAIN , CONF_COOL_TEMP , CONF_HEAT_TEMP , NatureRemoBase
2121
2222_LOGGER = logging .getLogger (__name__ )
2323
@@ -50,7 +50,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
5050 coordinator = hass .data [DOMAIN ]["coordinator" ]
5151 api = hass .data [DOMAIN ]["api" ]
5252 config = hass .data [DOMAIN ]["config" ]
53- appliances = coordinator .data
53+ appliances = coordinator .data [ "appliances" ]
5454 async_add_entities (
5555 [
5656 NatureRemoAC (coordinator , api , appliance , config )
@@ -60,47 +60,36 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
6060 )
6161
6262
63- class NatureRemoAC (ClimateEntity ):
63+ class NatureRemoAC (NatureRemoBase , ClimateEntity ):
6464 """Implementation of a Nature Remo E sensor."""
6565
6666 def __init__ (self , coordinator , api , appliance , config ):
67- self . _coordinator = coordinator
67+ super (). __init__ ( coordinator , appliance )
6868 self ._api = api
6969 self ._default_temp = {
7070 HVAC_MODE_COOL : config [CONF_COOL_TEMP ],
7171 HVAC_MODE_HEAT : config [CONF_HEAT_TEMP ],
7272 }
73- self ._name = f"Nature Remo { appliance ['nickname' ]} "
74- self ._appliance_id = appliance ["id" ]
7573 self ._modes = appliance ["aircon" ]["range" ]["modes" ]
7674 self ._hvac_mode = None
75+ self ._current_temperature = None
7776 self ._target_temperature = None
7877 self ._remo_mode = None
7978 self ._fan_mode = None
8079 self ._swing_mode = None
8180 self ._last_target_temperature = {v : None for v in MODE_REMO_TO_HA }
8281 self ._update (appliance ["settings" ])
8382
84- @property
85- def name (self ):
86- """Return the name of the sensor."""
87- return self ._name
88-
89- @property
90- def unique_id (self ):
91- """Return a unique ID."""
92- return self ._appliance_id
93-
94- @property
95- def should_poll (self ):
96- """Return the polling requirement of the entity."""
97- return False
98-
9983 @property
10084 def supported_features (self ):
10185 """Return the list of supported features."""
10286 return SUPPORT_FLAGS
10387
88+ @property
89+ def current_temperature (self ):
90+ """Return the current temperature."""
91+ return self ._current_temperature
92+
10493 @property
10594 def temperature_unit (self ):
10695 """Return the unit of measurement which this thermostat uses."""
@@ -216,7 +205,7 @@ async def async_update(self):
216205 """
217206 await self ._coordinator .async_request_refresh ()
218207
219- def _update (self , ac_settings ):
208+ def _update (self , ac_settings , device = None ):
220209 # hold this to determin the ac mode while it's turned-off
221210 self ._remo_mode = ac_settings ["mode" ]
222211 try :
@@ -233,9 +222,15 @@ def _update(self, ac_settings):
233222 self ._fan_mode = ac_settings ["vol" ] or None
234223 self ._swing_mode = ac_settings ["dir" ] or None
235224
225+ if device is not None :
226+ self ._current_temperature = float (device ["newest_events" ]["te" ]["val" ])
227+
236228 @callback
237229 def _update_callback (self ):
238- self ._update (self ._coordinator .data [self ._appliance_id ]["settings" ])
230+ self ._update (
231+ self ._coordinator .data ["appliances" ][self ._appliance_id ]["settings" ],
232+ self ._coordinator .data ["devices" ][self ._device ["id" ]],
233+ )
239234 self .async_write_ha_state ()
240235
241236 async def _post (self , data ):
0 commit comments