(self, data: RequestData, state: dict[str, Any])
Set device state.
Set device state.
Set device state .
async def set_state(self, data: RequestData, state: dict[str, Any]):
        """Set device state."""
        value = state['value']
        service = self.set_value

        if state.get('relative'):
            if self.increase_value or self.decrease_value:
                if value >= 0:
                    service = self.increase_value
                else:
                    service = self.decrease_value
            else:
                if not self.retrievable:
                    raise SmartHomeError(
                        ERR_NOT_SUPPORTED_IN_CURRENT_MODE,
                        f'Failed to set relative value for {self.instance} instance of {self.state.entity_id}. '
                        f'No state or service found.'
                    )

                value = self.get_absolute_value(state['value'])

        await async_call_from_config(
            self.hass,
            service,
            validate_config=False,
            variables={'value': value},
            blocking=True,
            context=data.context
        )
async def set_state ( self , data : RequestData , state : dict [ str , Any ] ) : value = state [ 'value' ] service = self . set_value if state . get ( 'relative' ) : if self . increase_value or self . decrease_value : if value >= 0 : service = self . increase_value else : service = self . decrease_value else : if not self . retrievable : raise SmartHomeError ( ERR_NOT_SUPPORTED_IN_CURRENT_MODE , f'Failed to set relative value for {self.instance} instance of {self.state.entity_id}. ' f'No state or service found.' ) value = self . get_absolute_value ( state [ 'value' ] ) await async_call_from_config ( self . hass , service , validate_config = False , variables = { 'value' : value } , blocking = True , context = data . context )