async def var_abs( self, var: lcn_defs.Var, value_or_float: Union[float, lcn_defs.VarValue], unit: lcn_defs.VarUnit = lcn_defs.VarUnit.NATIVE, software_serial: Optional[int] = None, ) -> bool: """Send a command to set the absolute value to a variable. :param Var var: Variable :param float value: Absolute value to set :param VarUnit unit: Unit of variable :returns: True if command was sent successfully, False otherwise :rtype: bool """ if isinstance(value_or_float, lcn_defs.VarValue): value = value_or_float else: value = lcn_defs.VarValue.from_var_unit(value_or_float, unit, True) if software_serial is None: await self.serial_known software_serial = self.software_serial if lcn_defs.Var.to_var_id(var) != -1: # Absolute commands for variables 1-12 are not supported if self.addr_id == 4 and self.is_group: # group 4 are status messages return await self.send_command( not self.is_group, PckGenerator.update_status_var(var, value.to_native()), ) # We fake the missing command by using reset and relative # commands. success = await self.send_command( not self.is_group, PckGenerator.var_reset(var, software_serial) ) if not success: return False return await self.send_command( not self.is_group, PckGenerator.var_rel( var, lcn_defs.RelVarRef.CURRENT, value.to_native(), software_serial ), ) return await self.send_command( not self.is_group, PckGenerator.var_abs(var, value.to_native()) )
async def var_reset(self, var: lcn_defs.Var, software_serial: Optional[int] = None) -> bool: """Send a command to reset the variable value. :param Var var: Variable :returns: True if command was sent successfully, False otherwise :rtype: bool """ if software_serial is None: await self.serial_known software_serial = self.software_serial return await self.send_command( not self.is_group, PckGenerator.var_reset(var, software_serial))