Skip to content

Commit

Permalink
Merge pull request #12 from JonasMH/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
JonasMH authored Sep 11, 2022
2 parents d2c0173 + 73d0194 commit 3e6c6b2
Show file tree
Hide file tree
Showing 4 changed files with 358 additions and 56 deletions.
87 changes: 31 additions & 56 deletions src/ToMqttNet/DeviceTypes/MqttClimateDiscoveryConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig
[JsonProperty("aux_state_topic")]
public string? AuxStateTopic { get; set; }

///<summary>
/// The MQTT topic to publish commands to change the away mode.
///</summary>
[JsonProperty("away_mode_command_topic")]
public string? AwayModeCommandTopic { get; set; }

///<summary>
/// A template to render the value received on the away_mode_state_topic with.
///</summary>
[JsonProperty("away_mode_state_template")]
public string? AwayModeStateTemplate { get; set; }

///<summary>
/// The MQTT topic to subscribe for changes of the HVAC away mode. If this is not set, the away mode works in optimistic mode (see below).
///</summary>
[JsonProperty("away_mode_state_topic")]
public string? AwayModeStateTopic { get; set; }

///<summary>
/// A template with which the value received on current_temperature_topic will be rendered.
///</summary>
Expand Down Expand Up @@ -123,44 +105,13 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig
[JsonProperty("fan_modes")]
public List<string>? FanModes { get; set; }

///<summary>
/// A template to render the value sent to the hold_command_topic with.
///</summary>
[JsonProperty("hold_command_template")]
public string? HoldCommandTemplate { get; set; }

///<summary>
/// The MQTT topic to publish commands to change the hold mode.
///</summary>
[JsonProperty("hold_command_topic")]
public string? HoldCommandTopic { get; set; }

///<summary>
/// A template to render the value received on the hold_state_topic with.
///</summary>
[JsonProperty("hold_state_template")]
public string? HoldStateTemplate { get; set; }

///<summary>
/// The MQTT topic to subscribe for changes of the HVAC hold mode. If this is not set, the hold mode works in optimistic mode (see below).
///</summary>
[JsonProperty("hold_state_topic")]
public string? HoldStateTopic { get; set; }

///<summary>
/// A list of available hold modes.
///</summary>
[JsonProperty("hold_modes")]
public List<string>? HoldModes { get; set; }

///<summary>
/// Set the initial target temperature.
/// , default: 21
///</summary>
[JsonProperty("initial")]
public long? Initial { get; set; }


///<summary>
/// Defines a template to extract the JSON dictionary from messages received on the json_attributes_topic. Usage example can be found in MQTT sensor documentation.
///</summary>
Expand Down Expand Up @@ -267,6 +218,37 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig
[JsonProperty("precision")]
public double? Precision { get; set; }

///<summary>
/// Defines a template to generate the payload to send to preset_mode_command_topic.
///</summary>
[JsonProperty("preset_mode_command_template")]
public string? PresetModeCommandTemplate { get; set; }

///<summary>
/// The MQTT topic to publish commands to change the preset mode.
///</summary>
[JsonProperty("preset_mode_command_topic")]
public string? PresetModeCommandTopic { get; set; }

///<summary>
/// The MQTT topic subscribed to receive climate speed based on presets. When preset ‘none’ is received or None the preset_mode will be reset.
///</summary>
[JsonProperty("preset_mode_state_topic")]
public string? PresetModeStateTopic { get; set; }

///<summary>
/// Defines a template to extract the preset_mode value from the payload received on preset_mode_state_topic.
///</summary>
[JsonProperty("preset_mode_value_template")]
public string? PresetModeValueTemplate { get; set; }

///<summary>
/// List of preset modes this climate is supporting. Common examples include eco, away, boost, comfort, home, sleep and activity.
/// , default: []
///</summary>
[JsonProperty("preset_modes")]
public List<string>? PresetModes { get; set; }

///<summary>
/// The maximum QoS level to be used when receiving and publishing messages.
/// , default: 0
Expand All @@ -281,13 +263,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig
[JsonProperty("retain")]
public bool? Retain { get; set; }

///<summary>
/// Set to false to suppress sending of all MQTT messages when the current mode is Off.
/// , default: true
///</summary>
[JsonProperty("send_if_off")]
public bool? SendIfOff { get; set; }

///<summary>
/// A template to render the value sent to the swing_mode_command_topic with.
///</summary>
Expand Down
6 changes: 6 additions & 0 deletions src/ToMqttNet/DeviceTypes/MqttSensorDiscoveryConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public class MqttSensorDiscoveryConfig : MqttDiscoveryConfig
[JsonProperty("last_reset_value_template")]
public string? LastResetValueTemplate { get; set; }

///<summary>
/// Last rest
///</summary>
[JsonProperty("last_reset")]
public string? LastReset { get; set; }

///<summary>
/// Used instead of name for automatic generation of entity_id
///</summary>
Expand Down
143 changes: 143 additions & 0 deletions src/ToMqttNet/HomeAssistantDeviceClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
namespace ToMqttNet
{
public class HomeAssistantDeviceClass
{
public string Value { get; }

public HomeAssistantDeviceClass(string value)
{
Value = value;
}

public override string ToString()
{
return Value;
}

/// <summary>
/// Apparent power in VA.
/// </summary>
public static HomeAssistantDeviceClass APPARENT_POWER { get; } = new HomeAssistantDeviceClass("apparent_power");
/// <summary>
/// Air Quality Index
/// </summary>
public static HomeAssistantDeviceClass AQI { get; } = new HomeAssistantDeviceClass("aqi");
/// <summary>
/// Percentage of battery that is left
/// </summary>
public static HomeAssistantDeviceClass BATTERY { get; } = new HomeAssistantDeviceClass("battery");
/// <summary>
/// Carbon Dioxide in CO2 (Smoke)
/// </summary>
public static HomeAssistantDeviceClass CARBON_DIOXIDE { get; } = new HomeAssistantDeviceClass("carbon_dioxide");
/// <summary>
/// Carbon Monoxide in CO (Gas CNG/LPG)
/// </summary>
public static HomeAssistantDeviceClass CARBON_MONOXIDE { get; } = new HomeAssistantDeviceClass("carbon_monoxide");
/// <summary>
/// Current in A
/// </summary>
public static HomeAssistantDeviceClass CURRENT { get; } = new HomeAssistantDeviceClass("current");
/// <summary>
/// Date string (ISO 8601)
/// </summary>
public static HomeAssistantDeviceClass DATE { get; } = new HomeAssistantDeviceClass("date");
/// <summary>
/// Duration in days, hours, minutes or seconds
/// </summary>
public static HomeAssistantDeviceClass DURATION { get; } = new HomeAssistantDeviceClass("duration");
/// <summary>
/// Energy in Wh, kWh or MWh
/// </summary>
public static HomeAssistantDeviceClass ENERGY { get; } = new HomeAssistantDeviceClass("energy");
/// <summary>
/// Frequency in Hz, kHz, MHz or GHz
/// </summary>
public static HomeAssistantDeviceClass FREQUENCY { get; } = new HomeAssistantDeviceClass("frequency");
/// <summary>
/// Gasvolume in m³ or ft³
/// </summary>
public static HomeAssistantDeviceClass GAS { get; } = new HomeAssistantDeviceClass("gas");
/// <summary>
/// Percentage of humidity in the air
/// </summary>
public static HomeAssistantDeviceClass HUMIDITY { get; } = new HomeAssistantDeviceClass("humidity");
/// <summary>
/// The current light level in lx or lm
/// </summary>
public static HomeAssistantDeviceClass ILLUMINANCE { get; } = new HomeAssistantDeviceClass("illuminance");
/// <summary>
/// The monetary value
/// </summary>
public static HomeAssistantDeviceClass MONETARY { get; } = new HomeAssistantDeviceClass("monetary");
/// <summary>
/// Concentration of Nitrogen Dioxide in µg/m³
/// </summary>
public static HomeAssistantDeviceClass NITROGEN_DIOXIDE { get; } = new HomeAssistantDeviceClass("nitrogen_dioxide");
/// <summary>
/// Concentration of Nitrogen Monoxide in µg/m³
/// </summary>
public static HomeAssistantDeviceClass NITROGEN_MONOXIDE { get; } = new HomeAssistantDeviceClass("nitrogen_monoxide");
/// <summary>
/// Concentration of Nitrous Oxide in µg/m³
/// </summary>
public static HomeAssistantDeviceClass NITROUS_OXIDE { get; } = new HomeAssistantDeviceClass("nitrous_oxide");
/// <summary>
/// Concentration of Ozone in µg/m³
/// </summary>
public static HomeAssistantDeviceClass OZONE { get; } = new HomeAssistantDeviceClass("ozone");
/// <summary>
/// Concentration of particulate matter less than 1 micrometer in µg/m³
/// </summary>
public static HomeAssistantDeviceClass PM1 { get; } = new HomeAssistantDeviceClass("pm1");
/// <summary>
/// Concentration of particulate matter less than 10 micrometers in µg/m³
/// </summary>
public static HomeAssistantDeviceClass PM10 { get; } = new HomeAssistantDeviceClass("pm10");
/// <summary>
/// Concentration of particulate matter less than 2.5 micrometers in µg/m³
/// </summary>
public static HomeAssistantDeviceClass PM25 { get; } = new HomeAssistantDeviceClass("pm25");
/// <summary>
/// Power factor in %
/// </summary>
public static HomeAssistantDeviceClass POWER_FACTOR { get; } = new HomeAssistantDeviceClass("power_factor");
/// <summary>
/// Power in W or kW
/// </summary>
public static HomeAssistantDeviceClass POWER { get; } = new HomeAssistantDeviceClass("power");
/// <summary>
/// Pressure in Pa, kPa, hPa, bar, cbar, mbar, mmHg, inHg or psi
/// </summary>
public static HomeAssistantDeviceClass PRESSURE { get; } = new HomeAssistantDeviceClass("pressure");
/// <summary>
/// Reactive power in var
/// </summary>
public static HomeAssistantDeviceClass REACTIVE_POWER { get; } = new HomeAssistantDeviceClass("reactive_power");
/// <summary>
/// Signal strength in dB or dBm
/// </summary>
public static HomeAssistantDeviceClass SIGNAL_STRENGTH { get; } = new HomeAssistantDeviceClass("signal_strength");
/// <summary>
/// Concentration of sulphur dioxide in µg/m³
/// </summary>
public static HomeAssistantDeviceClass SULPHUR_DIOXIDE { get; } = new HomeAssistantDeviceClass("sulphur_dioxide");
/// <summary>
/// Temperature in °C or °F
/// </summary>
public static HomeAssistantDeviceClass TEMPERATURE { get; } = new HomeAssistantDeviceClass("temperature");
/// <summary>
/// Datetime object or timestamp string (ISO 8601)
/// </summary>
public static HomeAssistantDeviceClass TIMESTAMP { get; } = new HomeAssistantDeviceClass("timestamp");
/// <summary>
/// Concentration of volatile organic compounds in µg/m³
/// </summary>
public static HomeAssistantDeviceClass VOLATILE_ORGANIC_COMPOUNDS { get; } = new HomeAssistantDeviceClass("volatile_organic_compounds");
/// <summary>
/// Voltage in V
/// </summary>
public static HomeAssistantDeviceClass VOLTAGE { get; } = new HomeAssistantDeviceClass("voltage");
}

}
Loading

0 comments on commit 3e6c6b2

Please sign in to comment.