Skip to content

Commit

Permalink
Fix: satellite sensor and command firendly name not saved properly (#169
Browse files Browse the repository at this point in the history
)

This PR fixes a bug causing some satellite sensors and commands to have improper friendly name (always equal to entityname)
  • Loading branch information
amadeo-alex authored Sep 27, 2024
1 parent 91ea787 commit 197a2fc
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ await Task.Run(delegate
{
Id = Guid.Parse(customCommand.Id),
EntityName = customCommand.EntityName,
Name = customCommand.EntityName,
Name = customCommand.Name,
Type = type,
EntityType = command.EntityType,
EntityType = customCommand.EntityType,
Command = customCommand.Command,
RunAsLowIntegrity = customCommand.RunAsLowIntegrity
};
Expand All @@ -186,9 +186,9 @@ await Task.Run(delegate
{
Id = Guid.Parse(powershellCommand.Id),
EntityName = powershellCommand.EntityName,
Name = powershellCommand.EntityName,
Name = powershellCommand.Name,
Type = type,
EntityType = command.EntityType,
EntityType = powershellCommand.EntityType,
Command = powershellCommand.Command
};
}
Expand All @@ -200,9 +200,9 @@ await Task.Run(delegate
{
Id = Guid.Parse(customKeyCommand.Id),
EntityName = customKeyCommand.EntityName,
Name = customKeyCommand.EntityName,
Name = customKeyCommand.Name,
Type = type,
EntityType = command.EntityType,
EntityType = customKeyCommand.EntityType,
KeyCode = customKeyCommand.KeyCode
};
}
Expand All @@ -214,10 +214,10 @@ await Task.Run(delegate
{
Id = Guid.Parse(internalCommand.Id),
EntityName = internalCommand.EntityName,
Name = internalCommand.EntityName,
Name = internalCommand.Name,
Command = internalCommand.CommandConfig ?? string.Empty,
Type = type,
EntityType = command.EntityType,
EntityType = internalCommand.EntityType,
};
}

Expand All @@ -228,10 +228,10 @@ await Task.Run(delegate
{
Id = Guid.Parse(multipleKeysCommand.Id),
EntityName = multipleKeysCommand.EntityName,
Name = multipleKeysCommand.EntityName,
Name = multipleKeysCommand.Name,
Keys = multipleKeysCommand.Keys ?? new List<string>(),
Type = type,
EntityType = command.EntityType,
EntityType = multipleKeysCommand.EntityType,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(namedWindowSensor.Id),
EntityName = namedWindowSensor.EntityName,
Name = namedWindowSensor.EntityName,
Name = namedWindowSensor.Name,
Type = type,
UpdateInterval = namedWindowSensor.UpdateIntervalSeconds,
IgnoreAvailability = namedWindowSensor.IgnoreAvailability,
Expand All @@ -266,7 +266,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(performanceCounterSensor.Id),
EntityName = performanceCounterSensor.EntityName,
Name = performanceCounterSensor.EntityName,
Name = performanceCounterSensor.Name,
Type = type,
UpdateInterval = performanceCounterSensor.UpdateIntervalSeconds,
IgnoreAvailability = performanceCounterSensor.IgnoreAvailability,
Expand All @@ -286,7 +286,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(processActiveSensor.Id),
EntityName = processActiveSensor.EntityName,
Name = processActiveSensor.EntityName,
Name = processActiveSensor.Name,
Type = type,
UpdateInterval = processActiveSensor.UpdateIntervalSeconds,
IgnoreAvailability = processActiveSensor.IgnoreAvailability,
Expand All @@ -302,7 +302,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(serviceStateSensor.Id),
EntityName = serviceStateSensor.EntityName,
Name = serviceStateSensor.EntityName,
Name = serviceStateSensor.Name,
Type = type,
UpdateInterval = serviceStateSensor.UpdateIntervalSeconds,
IgnoreAvailability = serviceStateSensor.IgnoreAvailability,
Expand All @@ -318,7 +318,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(powershellSensor.Id),
EntityName = powershellSensor.EntityName,
Name = powershellSensor.EntityName,
Name = powershellSensor.Name,
Type = type,
UpdateInterval = powershellSensor.UpdateIntervalSeconds,
IgnoreAvailability = powershellSensor.IgnoreAvailability,
Expand All @@ -336,7 +336,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(windowStateSensor.Id),
EntityName = windowStateSensor.EntityName,
Name = windowStateSensor.EntityName,
Name = windowStateSensor.Name,
Type = type,
UpdateInterval = windowStateSensor.UpdateIntervalSeconds,
IgnoreAvailability = windowStateSensor.IgnoreAvailability,
Expand All @@ -352,7 +352,7 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Name = sensor.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability,
Expand All @@ -377,10 +377,10 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = storageSensors.EntityName,
EntityName = storageSensors.EntityName,
Name = storageSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = storageSensors.UpdateIntervalSeconds
};
}

Expand All @@ -390,11 +390,11 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = networkSensors.EntityName,
EntityName = networkSensors.EntityName,
Name = networkSensors.Name,
Query = networkSensors.NetworkCard,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = networkSensors.UpdateIntervalSeconds
};
}

Expand All @@ -403,10 +403,11 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
_ = Enum.TryParse<SensorType>(windowsUpdatesSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Id = Guid.Parse(windowsUpdatesSensors.Id),
EntityName = windowsUpdatesSensors.EntityName,
Name = windowsUpdatesSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = windowsUpdatesSensors.UpdateIntervalSeconds
};
}

Expand All @@ -415,11 +416,11 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
_ = Enum.TryParse<SensorType>(batterySensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(batterySensors.Id),
EntityName = batterySensors.EntityName,
Name = batterySensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = batterySensors.UpdateIntervalSeconds
};
}

Expand All @@ -428,11 +429,11 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
_ = Enum.TryParse<SensorType>(displaySensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(displaySensors.Id),
EntityName = displaySensors.EntityName,
Name = displaySensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = displaySensors.UpdateIntervalSeconds
};
}

Expand All @@ -441,11 +442,11 @@ internal static ConfiguredSensor ConvertAbstractSingleValueToConfigured(Abstract
_ = Enum.TryParse<SensorType>(audioSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(audioSensors.Id),
EntityName = audioSensors.EntityName,
Name = audioSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds
UpdateInterval = audioSensors.UpdateIntervalSeconds
};
}
}
Expand Down
70 changes: 35 additions & 35 deletions src/HASS.Agent/HASS.Agent/Settings/StoredSensors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(storageSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(storageSensors.Id),
EntityName = storageSensors.EntityName,
Name = storageSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = storageSensors.UpdateIntervalSeconds,
IgnoreAvailability = storageSensors.IgnoreAvailability
};
}

Expand All @@ -479,13 +479,13 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(networkSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(networkSensors.Id),
EntityName = networkSensors.EntityName,
Name = networkSensors.Name,
Query = networkSensors.NetworkCard,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = networkSensors.UpdateIntervalSeconds,
IgnoreAvailability = networkSensors.IgnoreAvailability
};
}

Expand All @@ -494,12 +494,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(windowsUpdatesSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(windowsUpdatesSensors.Id),
EntityName = windowsUpdatesSensors.EntityName,
Name = windowsUpdatesSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = windowsUpdatesSensors.UpdateIntervalSeconds,
IgnoreAvailability = windowsUpdatesSensors.IgnoreAvailability
};
}

Expand All @@ -508,12 +508,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(batterySensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(batterySensors.Id),
EntityName = batterySensors.EntityName,
Name = batterySensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = batterySensors.UpdateIntervalSeconds,
IgnoreAvailability = batterySensors.IgnoreAvailability
};
}

Expand All @@ -522,12 +522,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(displaySensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(displaySensors.Id),
EntityName = displaySensors.EntityName,
Name = displaySensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = displaySensors.UpdateIntervalSeconds,
IgnoreAvailability = displaySensors.IgnoreAvailability
};
}

Expand All @@ -536,12 +536,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(audioSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(audioSensors.Id),
EntityName = audioSensors.EntityName,
Name = audioSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = audioSensors.UpdateIntervalSeconds,
IgnoreAvailability = audioSensors.IgnoreAvailability
};
}

Expand All @@ -550,12 +550,12 @@ internal static ConfiguredSensor ConvertAbstractMultiValueToConfigured(AbstractM
_ = Enum.TryParse<SensorType>(printersSensors.GetType().Name, out var type);
return new ConfiguredSensor
{
Id = Guid.Parse(sensor.Id),
EntityName = sensor.EntityName,
Name = sensor.EntityName,
Id = Guid.Parse(printersSensors.Id),
EntityName = printersSensors.EntityName,
Name = printersSensors.Name,
Type = type,
UpdateInterval = sensor.UpdateIntervalSeconds,
IgnoreAvailability = sensor.IgnoreAvailability
UpdateInterval = printersSensors.UpdateIntervalSeconds,
IgnoreAvailability = printersSensors.IgnoreAvailability
};
}
}
Expand Down

0 comments on commit 197a2fc

Please sign in to comment.