Skip to content

Commit

Permalink
feat: add currency, country and language fields to configuration model
Browse files Browse the repository at this point in the history
  • Loading branch information
vicfergar committed Jul 10, 2023
1 parent f408f02 commit 0f48c5f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions resources/tests/config/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
default_config:
homeassistant:
country: ES
latitude: 37.3886303
longitude: -5.9953403
elevation: 17

group: !include groups.yaml
automation: !include automations.yaml
Expand Down
13 changes: 13 additions & 0 deletions src/HassClient.Core/Models/ConfigurationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,21 @@ private string[] allowlist_external_dirs
/// <summary>
/// Gets the currency code according to ISO 4217 (column "Code" from <see href="https://en.wikipedia.org/wiki/ISO_4217#Active_codes"/>).
/// </summary>
[JsonProperty]
public string Currency { get; private set; }

/// <summary>
/// Gets the country code according to ISO 3166.1 alpha-2 (column "Code" from <see href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements"/>).
/// </summary>
[JsonProperty]
public string Country { get; private set; }

/// <summary>
/// Gets the language code according to RFC 5646 language tag (column "639-1" from <see href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes"/>).
/// </summary>
[JsonProperty]
public string Language { get; private set; }

/// <inheritdoc />
public override string ToString() => this.LocationName;
}
Expand Down
19 changes: 19 additions & 0 deletions src/HassClient.WS.Tests/ConfigurationApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void ConfigurationHasLocation()
Assert.NotNull(this.configuration.LocationName);
Assert.NotZero(this.configuration.Latitude);
Assert.NotZero(this.configuration.Longitude);
Assert.NotZero(this.configuration.Elevation);
}

[Test]
Expand Down Expand Up @@ -91,5 +92,23 @@ public void ConfigurationHasVersion()
{
Assert.NotNull(this.configuration.Version);
}

[Test]
public void ConfigurationHasCurrency()
{
Assert.NotNull(this.configuration.Currency);
}

[Test]
public void ConfigurationHasLanguage()
{
Assert.NotNull(this.configuration.Language);
}

[Test]
public void ConfigurationHasCountry()
{
Assert.NotNull(this.configuration.Country);
}
}
}

0 comments on commit 0f48c5f

Please sign in to comment.