Skip to content

Commit

Permalink
Add Debug Marker Fixes And Test Enviroment
Browse files Browse the repository at this point in the history
  • Loading branch information
GamerClassN7 committed May 24, 2024
1 parent ba8c82b commit f97dbf6
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 23 deletions.
8 changes: 7 additions & 1 deletion HA.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HA", "HA\HA.csproj", "{F4675A4D-373E-4C21-B77D-529E88181E5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HADC_REBORN", "HADC_REBORN\HADC_REBORN.csproj", "{3C0F1F5F-1ADE-4CF2-A5B5-348A41ABCD84}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HADC_REBORN", "HADC_REBORN\HADC_REBORN.csproj", "{3C0F1F5F-1ADE-4CF2-A5B5-348A41ABCD84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{8FC5E1BA-0D50-4D77-B6F9-B395ABCD6259}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +23,10 @@ Global
{3C0F1F5F-1ADE-4CF2-A5B5-348A41ABCD84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C0F1F5F-1ADE-4CF2-A5B5-348A41ABCD84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C0F1F5F-1ADE-4CF2-A5B5-348A41ABCD84}.Release|Any CPU.Build.0 = Release|Any CPU
{8FC5E1BA-0D50-4D77-B6F9-B395ABCD6259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FC5E1BA-0D50-4D77-B6F9-B395ABCD6259}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FC5E1BA-0D50-4D77-B6F9-B395ABCD6259}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FC5E1BA-0D50-4D77-B6F9-B395ABCD6259}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions HA/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

websocket:
ip_location:
debug:
keys:
websocket: true
# ip_location: false
debug: true
# keys: false

sensor:
- platform: wmic
Expand Down
51 changes: 35 additions & 16 deletions HADC_REBORN/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ public partial class App : System.Windows.Application
protected override void OnStartup(StartupEventArgs e)
{
AppDomain.CurrentDomain.FirstChanceException += GlobalExceptionFunction;

App.icon = new NotifyIcon();

icon.DoubleClick += new EventHandler(icon_Click);

icon.Icon = HADC_REBORN.Resource.ha_icon;

//Count for icon dakt mode change
Theme.setTheme(Theme.isLightTheme());

icon.Text = System.AppDomain.CurrentDomain.FriendlyName;
icon.Visible = true;

Expand All @@ -73,15 +76,42 @@ protected override void OnStartup(StartupEventArgs e)
icon.ContextMenuStrip.Items.Add("Send Test Notification", null, OnTestNotification_Click);
icon.ContextMenuStrip.Items.Add("Quit", null, OnQuit_Click);

base.OnStartup(e);

//On Color mode
UISettings settings = new UISettings();
Theme.setTheme(Theme.isColorLight(settings.GetColorValue(UIColorType.Background)));
settings.ColorValuesChanged += theme_Changed;

base.OnStartup(e);

log.writeLine("starting version: " + version);
}

public void loadYAMLComfig(bool force = false)
{
if (yamlLoader != null && !force)
{
return;
}

log.writeLine("looking for 'configuration.yaml'");
string configFilePath = Path.Combine(appDir, "configuration.yaml");
if (!File.Exists(configFilePath))
{
log.writeLine("'configuration.yaml' not found creating new one!");
File.WriteAllBytes(configFilePath, HADC_REBORN.Resource.configuration);
}
else
{
log.writeLine("'configuration.yaml' found!");
}
yamlLoader = new YamlLoader(configFilePath);
}

public Dictionary<string, Dictionary<string, Dictionary<string, List<Dictionary<string, dynamic>>>>> getYAMLComfig()
{
return yamlLoader.getConfigurationData();
}

private void theme_Changed(UISettings sender, object args)
{
Theme.setTheme(Theme.isColorLight(sender.GetColorValue(UIColorType.Background)));
Expand All @@ -106,24 +136,13 @@ private void Application_Startup(object sender, StartupEventArgs e)

public bool Start()
{
log.writeLine("looking for 'configuration.yaml'");
string configFilePath = Path.Combine(appDir, "configuration.yaml");
if (!File.Exists(configFilePath))
{
log.writeLine("'configuration.yaml' not found creating new one!");
File.WriteAllBytes(configFilePath, HADC_REBORN.Resource.configuration);
}
else
{
log.writeLine("'configuration.yaml' found!");
}
loadYAMLComfig(true);

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
string url = config.AppSettings.Settings["url"].Value;
string token = config.AppSettings.Settings["token"].Value;
log.setSecreets(new string[] { token, url.Replace("http://", "").Replace("https://", "")});

yamlLoader = new YamlLoader(configFilePath);

if (String.IsNullOrEmpty(url) || String.IsNullOrEmpty(token))
{
Expand Down
6 changes: 4 additions & 2 deletions HADC_REBORN/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public MainWindow()

statusTimer.Interval = TimeSpan.FromSeconds(5);
statusTimer.Tick += statusTimer_Tick;

app.loadYAMLComfig();
}

protected override void OnSourceInitialized(EventArgs e)
Expand Down Expand Up @@ -117,8 +119,8 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Title += (" - " + App.version);

if (App.yamlLoader.getConfigurationData().ContainsKey("debug"))
if (true)
{
Title += " - DEBUG";
}
Expand Down
13 changes: 13 additions & 0 deletions Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


using HADC_REBORN.Class.Helpers;

YamlLoader yaml = new YamlLoader("./configuration.yaml");




// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(yaml.getConfigurationData()));
20 changes: 20 additions & 0 deletions Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\HADC_REBORN\HADC_REBORN.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="configuration.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
120 changes: 120 additions & 0 deletions Test/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

websocket: true
# ip_location: false
debug: true
# keys: false

sensor:
- platform: wmic
wmic_class: Win32_LogicalDisk
wmic_selector: FreeSpace
wmic_namespace: root\CIMV2
name: "C Free Disk space"
unique_id: disk_0_space
icon: "mdi:tape-drive"
unit_of_measurement: "GB"
entity_category: "diagnostic"
update_interval: 10
filters:
- divide: 1073741824
accuracy_decimals: 1
- platform: wmic
wmic_class: Win32_Battery
wmic_selector: EstimatedChargeRemaining
wmic_namespace: root\CIMV2
name: Battery Level
unique_id: battery_level
icon: "mdi:battery"
unit_of_measurement: "%"
device_class: battery
entity_category: "diagnostic"
update_interval: 16
accuracy_decimals: 0
- platform: wmic
wmic_class: Win32_Battery
wmic_selector: BatteryStatus
wmic_namespace: root\CIMV2
name: Battery State
unique_id: battery_state
icon: "mdi:battery-minus"
entity_category: "diagnostic"
value_map: "Unknown|Discharging|On AC|Fully Charged|Low|Critical|Charging|Charging and High|Charging and Low|Charging and Critical|Undefined|Partially Charged"
- platform: wmic
wmic_class: Win32_OperatingSystem
wmic_selector: FreePhysicalMemory
wmic_namespace: root\CIMV2
name: Free Ram
unique_id: free_ram
unit_of_measurement: "GB"
icon: "mdi:clock"
entity_category: "diagnostic"
update_interval: 10
filters:
- divide: 1000000
accuracy_decimals: 1
- platform: wmic
wmic_class: Win32_Processor
wmic_selector: LoadPercentage
wmic_namespace: root\CIMV2
name: CPU Usage
unique_id: cpu_usage
unit_of_measurement: "%"
icon: "mdi:cpu-64-bit"
entity_category: "diagnostic"
accuracy_decimals: 0
update_interval: 10
- platform: network_interface
selector: "State"
name: Wifi State
unique_id: wifi_state
icon: "mdi:wifi"
update_interval: 10
- platform: network_interface
selector: "SSID"
deselector: "BSSID"
name: Wifi SSID
unique_id: wifi_ssid
icon: "mdi:wifi"
update_interval: 10
- platform: current_window
name: Currently Active Window
unique_id: currently_active_window
icon: "mdi:application"
update_interval: 20
- platform: uptime
name: Uptime
unique_id: uptime
icon: "mdi:timer-outline"
unit_of_measurement: "h"
entity_category: "diagnostic"
accuracy_decimals: 0

binary_sensor:
- platform: consent_store
consent_category: webcam
name: Camera in use
unique_id: camera_in_use
icon: "mdi:camera"
- platform: consent_store
consent_category: microphone
name: Microphone in use
unique_id: microphone_in_use
icon: "mdi:microphone"
- platform: consent_store
consent_category: location
name: Location in use
unique_id: location_in_use
icon: "mdi:crosshairs-gps"
- platform: wmic
wmic_class: BatteryStatus
wmic_selector: PowerOnline
wmic_namespace: root\wmi
name: Is Charging
unique_id: is_charging
icon: "mdi:power-plug-off"
device_class: plug
- platform: restart_pending
name: Restart required
unique_id: restart_pending
icon: "mdi:restart"
entity_category: "diagnostic"

0 comments on commit f97dbf6

Please sign in to comment.