custom_components/xiaomi_miot_raw/__init__.py
def _handle_coordinator_update(self) -> None:
        """Handle updated data from the coordinator."""
        dict1 = {}
        statedict = {}
        if self._cloud['did'] in self.coordinator.data:
            if all(item['code'] == -704042011 for item in self.coordinator.data[self._cloud['did']]):
                if self._available == True or self._available == None:
                    if OFFLINE_NOTIFY:
                        persistent_notification.async_create(
                            self._hass,
                            f"请注意，云端接入设备 **{self._name}** 已离线。",
                            "Xiaomi MIoT - 设备离线")
                    else:
                        _LOGGER.warn(f"请注意，云端接入设备 **{self._name}** 已离线。")
                self._available = False
            else:
                self._available = True
            for item in self.coordinator.data[self._cloud['did']]:
                if dict1.get(item['siid']):
                    dict1[item['siid']][item['piid']] = item.get('value')
                else:
                    dict1[item['siid']] = {}
                    dict1[item['siid']][item['piid']] = item.get('value')

            for key, value in self._mapping.items():
                try:
                    statedict[key] = dict1[value['siid']][value['piid']]
                except KeyError:
                    statedict[key] = None
        else:
            pass

        self._state_attrs.update(statedict)
        self._handle_platform_specific_attrs()
        self.async_write_ha_state()
        self.publish_updates()
Handle updated data from the coordinator.
Handle updated data from the coordinator.
Handle updated data from the coordinator .
def _handle_coordinator_update(self) -> None:
        dict1 = {}
        statedict = {}
        if self._cloud['did'] in self.coordinator.data:
            if all(item['code'] == -704042011 for item in self.coordinator.data[self._cloud['did']]):
                if self._available == True or self._available == None:
                    if OFFLINE_NOTIFY:
                        persistent_notification.async_create(
                            self._hass,
                            f"请注意，云端接入设备 **{self._name}** 已离线。",
                            "Xiaomi MIoT - 设备离线")
                    else:
                        _LOGGER.warn(f"请注意，云端接入设备 **{self._name}** 已离线。")
                self._available = False
            else:
                self._available = True
            for item in self.coordinator.data[self._cloud['did']]:
                if dict1.get(item['siid']):
                    dict1[item['siid']][item['piid']] = item.get('value')
                else:
                    dict1[item['siid']] = {}
                    dict1[item['siid']][item['piid']] = item.get('value')
            for key, value in self._mapping.items():
                try:
                    statedict[key] = dict1[value['siid']][value['piid']]
                except KeyError:
                    statedict[key] = None
        else:
            pass
        self._state_attrs.update(statedict)
        self._handle_platform_specific_attrs()
        self.async_write_ha_state()
        self.publish_updates()
def _handle_coordinator_update ( self ) -> None : dict1 = { } statedict = { } if self . _cloud [ 'did' ] in self . coordinator . data : if all ( item [ 'code' ] == - 704042011 for item in self . coordinator . data [ self . _cloud [ 'did' ] ] ) : if self . _available == True or self . _available == None : if OFFLINE_NOTIFY : persistent_notification . async_create ( self . _hass , f"请注意，云端接入设备 **{self._name}** 已离线。", "Xiaomi MIoT - 设备离线") else : _LOGGER . warn ( f"请注意，云端接入设备 **{self._name}** 已离线。") self . _available = False else : self . _available = True for item in self . coordinator . data [ self . _cloud [ 'did' ] ] : if dict1 . get ( item [ 'siid' ] ) : dict1 [ item [ 'siid' ] ] [ item [ 'piid' ] ] = item . get ( 'value' ) else : dict1 [ item [ 'siid' ] ] = { } dict1 [ item [ 'siid' ] ] [ item [ 'piid' ] ] = item . get ( 'value' ) for key , value in self . _mapping . items ( ) : try : statedict [ key ] = dict1 [ value [ 'siid' ] ] [ value [ 'piid' ] ] except KeyError : statedict [ key ] = None else : pass self . _state_attrs . update ( statedict ) self . _handle_platform_specific_attrs ( ) self . async_write_ha_state ( ) self . publish_updates ( )
Handle updated data from the coordinator.
Handle updated data from the coordinator .
"""Handle updated data from the coordinator."""
self