Skip to content

Commit

Permalink
Fix nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasMH committed Jan 10, 2024
1 parent 76e3711 commit bf7af0a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MqttLawnMowerDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand Down Expand Up @@ -79,6 +80,7 @@ public class MqttLawnMowerDiscoveryConfig : MqttDiscoveryConfig
///true if no activity_state_topic defined, else false.
///</summary>
[JsonPropertyName("optimistic")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Optimistic { get; set; }

///<summary>
Expand All @@ -98,6 +100,7 @@ public class MqttLawnMowerDiscoveryConfig : MqttDiscoveryConfig
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
Expand All @@ -117,5 +120,6 @@ public class MqttLawnMowerDiscoveryConfig : MqttDiscoveryConfig
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class MqttSirenDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand Down Expand Up @@ -81,6 +82,7 @@ public class MqttSirenDiscoveryConfig : MqttDiscoveryConfig
///true if no state_topic defined, else false.
///</summary>
[JsonPropertyName("optimistic")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Optimistic { get; set; }

///<summary>
Expand Down Expand Up @@ -116,13 +118,15 @@ public class MqttSirenDiscoveryConfig : MqttDiscoveryConfig
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
/// If the published message should have the retain flag on or not.
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }

///<summary>
Expand Down Expand Up @@ -160,12 +164,14 @@ public class MqttSirenDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("support_duration")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? SupportDuration { get; set; }

///<summary>
/// Set to true if the MQTT siren supports the volume_set service turn on parameter and enables the volume_level state attribute.
/// , default: true
///</summary>
[JsonPropertyName("support_volume_set")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? SupportVolumeSet { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class MqttTextDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand Down Expand Up @@ -59,13 +60,15 @@ public class MqttTextDiscoveryConfig : MqttDiscoveryConfig
/// , default: 255
///</summary>
[JsonPropertyName("max")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Max { get; set; }

///<summary>
/// The minimum size of a text being set or received.
/// , default: 0
///</summary>
[JsonPropertyName("min")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Min { get; set; }

///<summary>
Expand All @@ -92,13 +95,15 @@ public class MqttTextDiscoveryConfig : MqttDiscoveryConfig
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
/// If the published message should have the retain flag on or not.
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }

///<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MqttUpdateDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand Down Expand Up @@ -92,6 +93,7 @@ public class MqttUpdateDiscoveryConfig : MqttDiscoveryConfig
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
Expand All @@ -111,6 +113,7 @@ public class MqttUpdateDiscoveryConfig : MqttDiscoveryConfig
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }

///<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class MqttValveDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand Down Expand Up @@ -74,6 +75,7 @@ public class MqttValveDiscoveryConfig : MqttDiscoveryConfig
///false if the state or position topic is defined; true otherwise.
///</summary>
[JsonPropertyName("optimistic")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Optimistic { get; set; }

///<summary>
Expand Down Expand Up @@ -115,34 +117,39 @@ public class MqttValveDiscoveryConfig : MqttDiscoveryConfig
/// , default: 0
///</summary>
[JsonPropertyName("position_closed")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? PositionClosed { get; set; }

///<summary>
/// Number which represents open position. The valve’s position will be scaled to (position_closed…position_open) range when a service is called and scaled back when a value is received.
/// , default: 100
///</summary>
[JsonPropertyName("position_open")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? PositionOpen { get; set; }

///<summary>
/// The maximum QoS level to be used when receiving and publishing messages.
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
/// Set to true if the value reports the position or supports setting the position. Enabling the reports_position option will cause the position to be published instead of a payload defined by payload_open, payload_close or payload_stop. When receiving messages, state_topic will accept numeric payloads or one of the following state messages: open, opening, closed, or closing.
/// , default: false
///</summary>
[JsonPropertyName("reports_position")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? ReportsPosition { get; set; }

///<summary>
/// Defines if published messages should have the retain flag set.
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }

///<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class MqttWaterHeaterDiscoveryConfig : MqttDiscoveryConfig
/// , default: true
///</summary>
[JsonPropertyName("enabled_by_default")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? EnabledByDefault { get; set; }

///<summary>
Expand All @@ -46,6 +47,7 @@ public class MqttWaterHeaterDiscoveryConfig : MqttDiscoveryConfig
/// Set the initial target temperature. The default value depends on the temperature unit, and will be 43.3°C or 110°F.
///</summary>
[JsonPropertyName("initial")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Initial { get; set; }

///<summary>
Expand All @@ -64,12 +66,14 @@ public class MqttWaterHeaterDiscoveryConfig : MqttDiscoveryConfig
/// Maximum set point available. The default value depends on the temperature unit, and will be 60°C or 140°F.
///</summary>
[JsonPropertyName("max_temp")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public double? MaxTemp { get; set; }

///<summary>
/// Minimum set point available. The default value depends on the temperature unit, and will be 43.3°C or 110°F.
///</summary>
[JsonPropertyName("min_temp")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public double? MinTemp { get; set; }

///<summary>
Expand Down Expand Up @@ -118,6 +122,7 @@ public class MqttWaterHeaterDiscoveryConfig : MqttDiscoveryConfig
///true if no state topic defined, else false.
///</summary>
[JsonPropertyName("optimistic")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Optimistic { get; set; }

///<summary>
Expand Down Expand Up @@ -167,20 +172,23 @@ public class MqttWaterHeaterDiscoveryConfig : MqttDiscoveryConfig
///0.1 for Celsius and 1.0 for Fahrenheit.
///</summary>
[JsonPropertyName("precision")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public double? Precision { get; set; }

///<summary>
/// The maximum QoS level to be used when receiving and publishing messages.
/// , default: 0
///</summary>
[JsonPropertyName("qos")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public long? Qos { get; set; }

///<summary>
/// Defines if published messages should have the retain flag set.
/// , default: false
///</summary>
[JsonPropertyName("retain")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? Retain { get; set; }

///<summary>
Expand Down
1 change: 1 addition & 0 deletions src/HomeAssistantDiscoveryNet/MqttDiscoveryJsonContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace HomeAssistantDiscoveryNet;
[JsonSerializable(typeof(MqttSceneDiscoveryConfig))]
[JsonSerializable(typeof(MqttSelectDiscoveryConfig))]
[JsonSerializable(typeof(MqttSensorDiscoveryConfig))]
[JsonSerializable(typeof(MqttSirenDiscoveryConfig))]
[JsonSerializable(typeof(MqttSwitchDiscoveryConfig))]
[JsonSerializable(typeof(MqttTagScannerDiscoveryConfig))]
[JsonSerializable(typeof(MqttTemplateLightDiscoveryConfig))]
Expand Down

0 comments on commit bf7af0a

Please sign in to comment.