diff --git a/src/ToMqttNet/DeviceTypes/MqttClimateDiscoveryConfig.cs b/src/ToMqttNet/DeviceTypes/MqttClimateDiscoveryConfig.cs index c964b8e..9e64443 100644 --- a/src/ToMqttNet/DeviceTypes/MqttClimateDiscoveryConfig.cs +++ b/src/ToMqttNet/DeviceTypes/MqttClimateDiscoveryConfig.cs @@ -39,24 +39,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("aux_state_topic")] public string? AuxStateTopic { get; set; } - /// - /// The MQTT topic to publish commands to change the away mode. - /// - [JsonProperty("away_mode_command_topic")] - public string? AwayModeCommandTopic { get; set; } - - /// - /// A template to render the value received on the away_mode_state_topic with. - /// - [JsonProperty("away_mode_state_template")] - public string? AwayModeStateTemplate { get; set; } - - /// - /// 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). - /// - [JsonProperty("away_mode_state_topic")] - public string? AwayModeStateTopic { get; set; } - /// /// A template with which the value received on current_temperature_topic will be rendered. /// @@ -123,36 +105,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("fan_modes")] public List? FanModes { get; set; } - /// - /// A template to render the value sent to the hold_command_topic with. - /// - [JsonProperty("hold_command_template")] - public string? HoldCommandTemplate { get; set; } - - /// - /// The MQTT topic to publish commands to change the hold mode. - /// - [JsonProperty("hold_command_topic")] - public string? HoldCommandTopic { get; set; } - - /// - /// A template to render the value received on the hold_state_topic with. - /// - [JsonProperty("hold_state_template")] - public string? HoldStateTemplate { get; set; } - - /// - /// 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). - /// - [JsonProperty("hold_state_topic")] - public string? HoldStateTopic { get; set; } - - /// - /// A list of available hold modes. - /// - [JsonProperty("hold_modes")] - public List? HoldModes { get; set; } - /// /// Set the initial target temperature. /// , default: 21 @@ -160,7 +112,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("initial")] public long? Initial { get; set; } - /// /// 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. /// @@ -267,6 +218,37 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("precision")] public double? Precision { get; set; } + /// + /// Defines a template to generate the payload to send to preset_mode_command_topic. + /// + [JsonProperty("preset_mode_command_template")] + public string? PresetModeCommandTemplate { get; set; } + + /// + /// The MQTT topic to publish commands to change the preset mode. + /// + [JsonProperty("preset_mode_command_topic")] + public string? PresetModeCommandTopic { get; set; } + + /// + /// The MQTT topic subscribed to receive climate speed based on presets. When preset ‘none’ is received or None the preset_mode will be reset. + /// + [JsonProperty("preset_mode_state_topic")] + public string? PresetModeStateTopic { get; set; } + + /// + /// Defines a template to extract the preset_mode value from the payload received on preset_mode_state_topic. + /// + [JsonProperty("preset_mode_value_template")] + public string? PresetModeValueTemplate { get; set; } + + /// + /// List of preset modes this climate is supporting. Common examples include eco, away, boost, comfort, home, sleep and activity. + /// , default: [] + /// + [JsonProperty("preset_modes")] + public List? PresetModes { get; set; } + /// /// The maximum QoS level to be used when receiving and publishing messages. /// , default: 0 @@ -281,13 +263,6 @@ public class MqttClimateDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("retain")] public bool? Retain { get; set; } - /// - /// Set to false to suppress sending of all MQTT messages when the current mode is Off. - /// , default: true - /// - [JsonProperty("send_if_off")] - public bool? SendIfOff { get; set; } - /// /// A template to render the value sent to the swing_mode_command_topic with. /// diff --git a/src/ToMqttNet/DeviceTypes/MqttSensorDiscoveryConfig.cs b/src/ToMqttNet/DeviceTypes/MqttSensorDiscoveryConfig.cs index 7d95d59..1f6e2c8 100644 --- a/src/ToMqttNet/DeviceTypes/MqttSensorDiscoveryConfig.cs +++ b/src/ToMqttNet/DeviceTypes/MqttSensorDiscoveryConfig.cs @@ -70,6 +70,12 @@ public class MqttSensorDiscoveryConfig : MqttDiscoveryConfig [JsonProperty("last_reset_value_template")] public string? LastResetValueTemplate { get; set; } + /// + /// Last rest + /// + [JsonProperty("last_reset")] + public string? LastReset { get; set; } + /// /// Used instead of name for automatic generation of entity_id /// diff --git a/src/ToMqttNet/HomeAssistantDeviceClass.cs b/src/ToMqttNet/HomeAssistantDeviceClass.cs new file mode 100644 index 0000000..2af30b7 --- /dev/null +++ b/src/ToMqttNet/HomeAssistantDeviceClass.cs @@ -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; + } + + /// + /// Apparent power in VA. + /// + public static HomeAssistantDeviceClass APPARENT_POWER { get; } = new HomeAssistantDeviceClass("apparent_power"); + /// + /// Air Quality Index + /// + public static HomeAssistantDeviceClass AQI { get; } = new HomeAssistantDeviceClass("aqi"); + /// + /// Percentage of battery that is left + /// + public static HomeAssistantDeviceClass BATTERY { get; } = new HomeAssistantDeviceClass("battery"); + /// + /// Carbon Dioxide in CO2 (Smoke) + /// + public static HomeAssistantDeviceClass CARBON_DIOXIDE { get; } = new HomeAssistantDeviceClass("carbon_dioxide"); + /// + /// Carbon Monoxide in CO (Gas CNG/LPG) + /// + public static HomeAssistantDeviceClass CARBON_MONOXIDE { get; } = new HomeAssistantDeviceClass("carbon_monoxide"); + /// + /// Current in A + /// + public static HomeAssistantDeviceClass CURRENT { get; } = new HomeAssistantDeviceClass("current"); + /// + /// Date string (ISO 8601) + /// + public static HomeAssistantDeviceClass DATE { get; } = new HomeAssistantDeviceClass("date"); + /// + /// Duration in days, hours, minutes or seconds + /// + public static HomeAssistantDeviceClass DURATION { get; } = new HomeAssistantDeviceClass("duration"); + /// + /// Energy in Wh, kWh or MWh + /// + public static HomeAssistantDeviceClass ENERGY { get; } = new HomeAssistantDeviceClass("energy"); + /// + /// Frequency in Hz, kHz, MHz or GHz + /// + public static HomeAssistantDeviceClass FREQUENCY { get; } = new HomeAssistantDeviceClass("frequency"); + /// + /// Gasvolume in m³ or ft³ + /// + public static HomeAssistantDeviceClass GAS { get; } = new HomeAssistantDeviceClass("gas"); + /// + /// Percentage of humidity in the air + /// + public static HomeAssistantDeviceClass HUMIDITY { get; } = new HomeAssistantDeviceClass("humidity"); + /// + /// The current light level in lx or lm + /// + public static HomeAssistantDeviceClass ILLUMINANCE { get; } = new HomeAssistantDeviceClass("illuminance"); + /// + /// The monetary value + /// + public static HomeAssistantDeviceClass MONETARY { get; } = new HomeAssistantDeviceClass("monetary"); + /// + /// Concentration of Nitrogen Dioxide in µg/m³ + /// + public static HomeAssistantDeviceClass NITROGEN_DIOXIDE { get; } = new HomeAssistantDeviceClass("nitrogen_dioxide"); + /// + /// Concentration of Nitrogen Monoxide in µg/m³ + /// + public static HomeAssistantDeviceClass NITROGEN_MONOXIDE { get; } = new HomeAssistantDeviceClass("nitrogen_monoxide"); + /// + /// Concentration of Nitrous Oxide in µg/m³ + /// + public static HomeAssistantDeviceClass NITROUS_OXIDE { get; } = new HomeAssistantDeviceClass("nitrous_oxide"); + /// + /// Concentration of Ozone in µg/m³ + /// + public static HomeAssistantDeviceClass OZONE { get; } = new HomeAssistantDeviceClass("ozone"); + /// + /// Concentration of particulate matter less than 1 micrometer in µg/m³ + /// + public static HomeAssistantDeviceClass PM1 { get; } = new HomeAssistantDeviceClass("pm1"); + /// + /// Concentration of particulate matter less than 10 micrometers in µg/m³ + /// + public static HomeAssistantDeviceClass PM10 { get; } = new HomeAssistantDeviceClass("pm10"); + /// + /// Concentration of particulate matter less than 2.5 micrometers in µg/m³ + /// + public static HomeAssistantDeviceClass PM25 { get; } = new HomeAssistantDeviceClass("pm25"); + /// + /// Power factor in % + /// + public static HomeAssistantDeviceClass POWER_FACTOR { get; } = new HomeAssistantDeviceClass("power_factor"); + /// + /// Power in W or kW + /// + public static HomeAssistantDeviceClass POWER { get; } = new HomeAssistantDeviceClass("power"); + /// + /// Pressure in Pa, kPa, hPa, bar, cbar, mbar, mmHg, inHg or psi + /// + public static HomeAssistantDeviceClass PRESSURE { get; } = new HomeAssistantDeviceClass("pressure"); + /// + /// Reactive power in var + /// + public static HomeAssistantDeviceClass REACTIVE_POWER { get; } = new HomeAssistantDeviceClass("reactive_power"); + /// + /// Signal strength in dB or dBm + /// + public static HomeAssistantDeviceClass SIGNAL_STRENGTH { get; } = new HomeAssistantDeviceClass("signal_strength"); + /// + /// Concentration of sulphur dioxide in µg/m³ + /// + public static HomeAssistantDeviceClass SULPHUR_DIOXIDE { get; } = new HomeAssistantDeviceClass("sulphur_dioxide"); + /// + /// Temperature in °C or °F + /// + public static HomeAssistantDeviceClass TEMPERATURE { get; } = new HomeAssistantDeviceClass("temperature"); + /// + /// Datetime object or timestamp string (ISO 8601) + /// + public static HomeAssistantDeviceClass TIMESTAMP { get; } = new HomeAssistantDeviceClass("timestamp"); + /// + /// Concentration of volatile organic compounds in µg/m³ + /// + public static HomeAssistantDeviceClass VOLATILE_ORGANIC_COMPOUNDS { get; } = new HomeAssistantDeviceClass("volatile_organic_compounds"); + /// + /// Voltage in V + /// + public static HomeAssistantDeviceClass VOLTAGE { get; } = new HomeAssistantDeviceClass("voltage"); + } + +} diff --git a/src/ToMqttNet/HomeAssistantUnits.cs b/src/ToMqttNet/HomeAssistantUnits.cs new file mode 100644 index 0000000..bfd94e6 --- /dev/null +++ b/src/ToMqttNet/HomeAssistantUnits.cs @@ -0,0 +1,178 @@ +namespace ToMqttNet +{ + public class HomeAssistantUnits + { + public string Value { get; } + + public HomeAssistantUnits(string value) + { + Value = value; + } + + public override string ToString() + { + return Value; + } + + + + // Power units + public static HomeAssistantUnits POWER_WATT { get; } = new HomeAssistantUnits("W"); + public static HomeAssistantUnits POWER_KILO_WATT { get; } = new HomeAssistantUnits("kW"); + + // Voltage units + public static HomeAssistantUnits VOLT { get; } = new HomeAssistantUnits("V"); + + // Energy units + public static HomeAssistantUnits ENERGY_WATT_HOUR { get; } = new HomeAssistantUnits("Wh"); + public static HomeAssistantUnits ENERGY_KILO_WATT_HOUR { get; } = new HomeAssistantUnits("kWh"); + + // Electrical units + public static HomeAssistantUnits ELECTRICAL_CURRENT_AMPERE { get; } = new HomeAssistantUnits("A"); + public static HomeAssistantUnits ELECTRICAL_VOLT_AMPERE { get; } = new HomeAssistantUnits("VA"); + + // Degree units + public static HomeAssistantUnits DEGREE { get; } = new HomeAssistantUnits("°"); + + // Currency units + public static HomeAssistantUnits CURRENCY_EURO { get; } = new HomeAssistantUnits("€"); + public static HomeAssistantUnits CURRENCY_DOLLAR { get; } = new HomeAssistantUnits("$"); + public static HomeAssistantUnits CURRENCY_CENT { get; } = new HomeAssistantUnits("¢"); + + // Temperature units + public static HomeAssistantUnits TEMP_CELSIUS { get; } = new HomeAssistantUnits("°C"); + public static HomeAssistantUnits TEMP_FAHRENHEIT { get; } = new HomeAssistantUnits("°F"); + public static HomeAssistantUnits TEMP_KELVIN { get; } = new HomeAssistantUnits("K"); + + // Time units + public static HomeAssistantUnits TIME_MICROSECONDS { get; } = new HomeAssistantUnits("μs"); + public static HomeAssistantUnits TIME_MILLISECONDS { get; } = new HomeAssistantUnits("ms"); + public static HomeAssistantUnits TIME_SECONDS { get; } = new HomeAssistantUnits("s"); + public static HomeAssistantUnits TIME_MINUTES { get; } = new HomeAssistantUnits("min"); + public static HomeAssistantUnits TIME_HOURS { get; } = new HomeAssistantUnits("h"); + public static HomeAssistantUnits TIME_DAYS { get; } = new HomeAssistantUnits("d"); + public static HomeAssistantUnits TIME_WEEKS { get; } = new HomeAssistantUnits("w"); + public static HomeAssistantUnits TIME_MONTHS { get; } = new HomeAssistantUnits("m"); + public static HomeAssistantUnits TIME_YEARS { get; } = new HomeAssistantUnits("y"); + + // Length units + public static HomeAssistantUnits LENGTH_MILLIMETERS { get; } = new HomeAssistantUnits("mm"); + public static HomeAssistantUnits LENGTH_CENTIMETERS { get; } = new HomeAssistantUnits("cm"); + public static HomeAssistantUnits LENGTH_METERS { get; } = new HomeAssistantUnits("m"); + public static HomeAssistantUnits LENGTH_KILOMETERS { get; } = new HomeAssistantUnits("km"); + + public static HomeAssistantUnits LENGTH_INCHES { get; } = new HomeAssistantUnits("in"); + public static HomeAssistantUnits LENGTH_FEET { get; } = new HomeAssistantUnits("ft"); + public static HomeAssistantUnits LENGTH_YARD { get; } = new HomeAssistantUnits("yd"); + public static HomeAssistantUnits LENGTH_MILES { get; } = new HomeAssistantUnits("mi"); + + // Frequency units + public static HomeAssistantUnits FREQUENCY_HERTZ { get; } = new HomeAssistantUnits("Hz"); + public static HomeAssistantUnits FREQUENCY_GIGAHERTZ { get; } = new HomeAssistantUnits("GHz"); + + // Pressure units + public static HomeAssistantUnits PRESSURE_PA { get; } = new HomeAssistantUnits("Pa"); + public static HomeAssistantUnits PRESSURE_HPA { get; } = new HomeAssistantUnits("hPa"); + public static HomeAssistantUnits PRESSURE_BAR { get; } = new HomeAssistantUnits("bar"); + public static HomeAssistantUnits PRESSURE_MBAR { get; } = new HomeAssistantUnits("mbar"); + public static HomeAssistantUnits PRESSURE_INHG { get; } = new HomeAssistantUnits("inHg"); + public static HomeAssistantUnits PRESSURE_PSI { get; } = new HomeAssistantUnits("psi"); + + // Volume units + public static HomeAssistantUnits VOLUME_LITERS { get; } = new HomeAssistantUnits("L"); + public static HomeAssistantUnits VOLUME_MILLILITERS { get; } = new HomeAssistantUnits("mL"); + public static HomeAssistantUnits VOLUME_CUBIC_METERS { get; } = new HomeAssistantUnits("m³"); + public static HomeAssistantUnits VOLUME_CUBIC_FEET { get; } = new HomeAssistantUnits("ft³"); + + public static HomeAssistantUnits VOLUME_GALLONS { get; } = new HomeAssistantUnits("gal"); + public static HomeAssistantUnits VOLUME_FLUID_OUNCE { get; } = new HomeAssistantUnits("fl. oz."); + + // Volume Flow Rate units + public static HomeAssistantUnits VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR { get; } = new HomeAssistantUnits("m³/h"); + public static HomeAssistantUnits VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE { get; } = new HomeAssistantUnits("ft³/m"); + + // Area units + public static HomeAssistantUnits AREA_SQUARE_METERS { get; } = new HomeAssistantUnits("m²"); + + // Mass units + public static HomeAssistantUnits MASS_GRAMS { get; } = new HomeAssistantUnits("g"); + public static HomeAssistantUnits MASS_KILOGRAMS { get; } = new HomeAssistantUnits("kg"); + public static HomeAssistantUnits MASS_MILLIGRAMS { get; } = new HomeAssistantUnits("mg"); + public static HomeAssistantUnits MASS_MICROGRAMS { get; } = new HomeAssistantUnits("µg"); + + public static HomeAssistantUnits MASS_OUNCES { get; } = new HomeAssistantUnits("oz"); + public static HomeAssistantUnits MASS_POUNDS { get; } = new HomeAssistantUnits("lb"); + + // Conductivity units + public static HomeAssistantUnits CONDUCTIVITY { get; } = new HomeAssistantUnits("µS/cm"); + + // Light units + public static HomeAssistantUnits LIGHT_LUX { get; } = new HomeAssistantUnits("lx"); + + // UV Index units + public static HomeAssistantUnits UV_INDEX { get; } = new HomeAssistantUnits("UV index"); + + // Percentage units + public static HomeAssistantUnits PERCENTAGE { get; } = new HomeAssistantUnits("%"); + + // Irradiation units + public static HomeAssistantUnits IRRADIATION_WATTS_PER_SQUARE_METER { get; } = new HomeAssistantUnits("W/m²"); + + // Precipitation units + public static HomeAssistantUnits PRECIPITATION_MILLIMETERS_PER_HOUR { get; } = new HomeAssistantUnits("mm/h"); + + // Concentration units + public static HomeAssistantUnits CONCENTRATION_MICROGRAMS_PER_CUBIC_METER { get; } = new HomeAssistantUnits("µg/m³"); + public static HomeAssistantUnits CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER { get; } = new HomeAssistantUnits("mg/m³"); + public static HomeAssistantUnits CONCENTRATION_PARTS_PER_CUBIC_METER { get; } = new HomeAssistantUnits("p/m³"); + public static HomeAssistantUnits CONCENTRATION_PARTS_PER_MILLION { get; } = new HomeAssistantUnits("ppm"); + public static HomeAssistantUnits CONCENTRATION_PARTS_PER_BILLION { get; } = new HomeAssistantUnits("ppb"); + + // Speed units + public static HomeAssistantUnits SPEED_MILLIMETERS_PER_DAY { get; } = new HomeAssistantUnits("mm/d"); + public static HomeAssistantUnits SPEED_INCHES_PER_DAY { get; } = new HomeAssistantUnits("in/d"); + public static HomeAssistantUnits SPEED_METERS_PER_SECOND { get; } = new HomeAssistantUnits("m/s"); + public static HomeAssistantUnits SPEED_INCHES_PER_HOUR { get; } = new HomeAssistantUnits("in/h"); + public static HomeAssistantUnits SPEED_KILOMETERS_PER_HOUR { get; } = new HomeAssistantUnits("km/h"); + public static HomeAssistantUnits SPEED_MILES_PER_HOUR { get; } = new HomeAssistantUnits("mph"); + + // Signal_strength units + public static HomeAssistantUnits SIGNAL_STRENGTH_DECIBELS { get; } = new HomeAssistantUnits("dB"); + public static HomeAssistantUnits SIGNAL_STRENGTH_DECIBELS_MILLIWATT { get; } = new HomeAssistantUnits("dBm"); + + // Data units + public static HomeAssistantUnits DATA_BITS { get; } = new HomeAssistantUnits("bit"); + public static HomeAssistantUnits DATA_KILOBITS { get; } = new HomeAssistantUnits("kbit"); + public static HomeAssistantUnits DATA_MEGABITS { get; } = new HomeAssistantUnits("Mbit"); + public static HomeAssistantUnits DATA_GIGABITS { get; } = new HomeAssistantUnits("Gbit"); + public static HomeAssistantUnits DATA_BYTES { get; } = new HomeAssistantUnits("B"); + public static HomeAssistantUnits DATA_KILOBYTES { get; } = new HomeAssistantUnits("kB"); + public static HomeAssistantUnits DATA_MEGABYTES { get; } = new HomeAssistantUnits("MB"); + public static HomeAssistantUnits DATA_GIGABYTES { get; } = new HomeAssistantUnits("GB"); + public static HomeAssistantUnits DATA_TERABYTES { get; } = new HomeAssistantUnits("TB"); + public static HomeAssistantUnits DATA_PETABYTES { get; } = new HomeAssistantUnits("PB"); + public static HomeAssistantUnits DATA_EXABYTES { get; } = new HomeAssistantUnits("EB"); + public static HomeAssistantUnits DATA_ZETTABYTES { get; } = new HomeAssistantUnits("ZB"); + public static HomeAssistantUnits DATA_YOTTABYTES { get; } = new HomeAssistantUnits("YB"); + public static HomeAssistantUnits DATA_KIBIBYTES { get; } = new HomeAssistantUnits("KiB"); + public static HomeAssistantUnits DATA_MEBIBYTES { get; } = new HomeAssistantUnits("MiB"); + public static HomeAssistantUnits DATA_GIBIBYTES { get; } = new HomeAssistantUnits("GiB"); + public static HomeAssistantUnits DATA_TEBIBYTES { get; } = new HomeAssistantUnits("TiB"); + public static HomeAssistantUnits DATA_PEBIBYTES { get; } = new HomeAssistantUnits("PiB"); + public static HomeAssistantUnits DATA_EXBIBYTES { get; } = new HomeAssistantUnits("EiB"); + public static HomeAssistantUnits DATA_ZEBIBYTES { get; } = new HomeAssistantUnits("ZiB"); + public static HomeAssistantUnits DATA_YOBIBYTES { get; } = new HomeAssistantUnits("YiB"); + public static HomeAssistantUnits DATA_RATE_BITS_PER_SECOND { get; } = new HomeAssistantUnits("bit/s"); + public static HomeAssistantUnits DATA_RATE_KILOBITS_PER_SECOND { get; } = new HomeAssistantUnits("kbit/s"); + public static HomeAssistantUnits DATA_RATE_MEGABITS_PER_SECOND { get; } = new HomeAssistantUnits("Mbit/s"); + public static HomeAssistantUnits DATA_RATE_GIGABITS_PER_SECOND { get; } = new HomeAssistantUnits("Gbit/s"); + public static HomeAssistantUnits DATA_RATE_BYTES_PER_SECOND { get; } = new HomeAssistantUnits("B/s"); + public static HomeAssistantUnits DATA_RATE_KILOBYTES_PER_SECOND { get; } = new HomeAssistantUnits("kB/s"); + public static HomeAssistantUnits DATA_RATE_MEGABYTES_PER_SECOND { get; } = new HomeAssistantUnits("MB/s"); + public static HomeAssistantUnits DATA_RATE_GIGABYTES_PER_SECOND { get; } = new HomeAssistantUnits("GB/s"); + public static HomeAssistantUnits DATA_RATE_KIBIBYTES_PER_SECOND { get; } = new HomeAssistantUnits("KiB/s"); + public static HomeAssistantUnits DATA_RATE_MEBIBYTES_PER_SECOND { get; } = new HomeAssistantUnits("MiB/s"); + public static HomeAssistantUnits DATA_RATE_GIBIBYTES_PER_SECOND { get; } = new HomeAssistantUnits("GiB/s"); + } + +}