Skip to content

Commit

Permalink
Add all types
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasMH committed Feb 17, 2022
1 parent b6a66b2 commit 2e9d3d7
Show file tree
Hide file tree
Showing 21 changed files with 2,606 additions and 78 deletions.
182 changes: 182 additions & 0 deletions src/ToMqttNet/DeviceTypes/MqttAlarmControlPanelDiscoveryConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
using Newtonsoft.Json;

namespace ToMqttNet
{
/// <summary>
/// The mqtt alarm panel platform enables the possibility to control MQTT capable alarm panels. The Alarm icon will change state after receiving a new state from state_topic. If these messages are published with RETAIN flag, the MQTT alarm panel will receive an instant state update after subscription and will start with the correct state. Otherwise, the initial state will be unknown.
/// </summary>
public class MqttAlarmControlPanelDiscoveryConfig : MqttDiscoveryConfig
{
public override string Component => "alarm_control_panel";


///<summary>
/// If defined, specifies a code to enable or disable the alarm in the frontend. Note that the code is validated locally and blocks sending MQTT messages to the remote device. For remote code validation, the code can be configured to either of the special values REMOTE_CODE (numeric code) or REMOTE_CODE_TEXT (text code). In this case, local code validation is bypassed but the frontend will still show a numeric or text code dialog. Use command_template to send the code to the remote device. Example configurations for remote code validation can be found here.
///</summary>
[JsonProperty("code")]
public string? Code { get; set; }

///<summary>
/// If true the code is required to arm the alarm. If false the code is not validated.
/// , default: true
///</summary>
[JsonProperty("code_arm_required")]
public bool? CodeArmRequired { get; set; }

///<summary>
/// If true the code is required to disarm the alarm. If false the code is not validated.
/// , default: true
///</summary>
[JsonProperty("code_disarm_required")]
public bool? CodeDisarmRequired { get; set; }

///<summary>
/// If true the code is required to trigger the alarm. If false the code is not validated.
/// , default: true
///</summary>
[JsonProperty("code_trigger_required")]
public bool? CodeTriggerRequired { get; set; }

///<summary>
/// The template used for the command payload. Available variables: action and code.
/// , default: action
///</summary>
[JsonProperty("command_template")]
public string? CommandTemplate { get; set; }

///<summary>
/// The MQTT topic to publish commands to change the alarm state.
///</summary>
[JsonProperty("command_topic")]
public string CommandTopic { get; set; }

///<summary>
/// Flag which defines if the entity should be enabled when first added.
/// , default: true
///</summary>
[JsonProperty("enabled_by_default")]
public bool? EnabledByDefault { get; set; }

///<summary>
/// The encoding of the payloads received and published messages. Set to "" to disable decoding of incoming payload.
/// , default: utf-8
///</summary>
[JsonProperty("encoding")]
public string? Encoding { get; set; }

///<summary>
/// The category of the entity.
/// , default: None
///</summary>
[JsonProperty("entity_category")]
public string? EntityCategory { 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>
[JsonProperty("json_attributes_template")]
public string? JsonAttributesTemplate { get; set; }

///<summary>
/// The MQTT topic subscribed to receive a JSON dictionary payload and then set as sensor attributes. Usage example can be found in MQTT sensor documentation.
///</summary>
[JsonProperty("json_attributes_topic")]
public string? JsonAttributesTopic { get; set; }

///<summary>
/// Used instead of name for automatic generation of entity_id
///</summary>
[JsonProperty("object_id")]
public string? ObjectId { get; set; }

///<summary>
/// The payload to set armed-away mode on your Alarm Panel.
/// , default: ARM_AWAY
///</summary>
[JsonProperty("payload_arm_away")]
public string? PayloadArmAway { get; set; }

///<summary>
/// The payload to set armed-home mode on your Alarm Panel.
/// , default: ARM_HOME
///</summary>
[JsonProperty("payload_arm_home")]
public string? PayloadArmHome { get; set; }

///<summary>
/// The payload to set armed-night mode on your Alarm Panel.
/// , default: ARM_NIGHT
///</summary>
[JsonProperty("payload_arm_night")]
public string? PayloadArmNight { get; set; }

///<summary>
/// The payload to set armed-vacation mode on your Alarm Panel.
/// , default: ARM_VACATION
///</summary>
[JsonProperty("payload_arm_vacation")]
public string? PayloadArmVacation { get; set; }

///<summary>
/// The payload to set armed-custom-bypass mode on your Alarm Panel.
/// , default: ARM_CUSTOM_BYPASS
///</summary>
[JsonProperty("payload_arm_custom_bypass")]
public string? PayloadArmCustomBypass { get; set; }

///<summary>
/// The payload that represents the available state.
/// , default: online
///</summary>
[JsonProperty("payload_available")]
public string? PayloadAvailable { get; set; }

///<summary>
/// The payload to disarm your Alarm Panel.
/// , default: DISARM
///</summary>
[JsonProperty("payload_disarm")]
public string? PayloadDisarm { get; set; }

///<summary>
/// The payload that represents the unavailable state.
/// , default: offline
///</summary>
[JsonProperty("payload_not_available")]
public string? PayloadNotAvailable { get; set; }

///<summary>
/// The payload to trigger the alarm on your Alarm Panel.
/// , default: TRIGGER
///</summary>
[JsonProperty("payload_trigger")]
public string? PayloadTrigger { get; set; }

///<summary>
/// The maximum QoS level of the state topic.
/// , default: 0
///</summary>
[JsonProperty("qos")]
public long? Qos { get; set; }

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

///<summary>
/// The MQTT topic subscribed to receive state updates.
///</summary>
[JsonProperty("state_topic")]
public string StateTopic { get; set; }

///<summary>
/// Defines a template to extract the value.
///</summary>
[JsonProperty("value_template")]
public string? ValueTemplate { get; set; }

}
}
118 changes: 101 additions & 17 deletions src/ToMqttNet/DeviceTypes/MqttBinarySensorDiscoveryConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,119 @@ namespace ToMqttNet
/// <summary>
/// The mqtt binary sensor platform uses an MQTT message received to set the binary sensor’s state to on or off.
/// </summary>
public class MqttBinarySensorDiscoveryConfig : MqttDiscoveryConfig<MqttSelectDiscoveryConfig>
public class MqttBinarySensorDiscoveryConfig : MqttDiscoveryConfig
{
public override string Component => "binary_sensor";

[JsonProperty("state_topic")]
public string? StateTopic { get; set; }
///<summary>
/// Sets the class of the device, changing the device state and icon that is displayed on the frontend.
///</summary>
[JsonProperty("device_class")]
public string? DeviceClass { get; set; }

/// <summary>
/// Defines a template that returns a string to be compared to <c>payload_on</c>/<c>payload_off</c> or an empty string, in which case the MQTT message will be removed. Available variables: entity_id. Remove this option when ‘payload_on’ and ‘payload_off’ are sufficient to match your payloads (i.e no pre-processing of original message is required).
/// </summary>
[JsonProperty("value_template")]
public string? ValueTemplate { get; set; }
///<summary>
/// Flag which defines if the entity should be enabled when first added.
/// , default: true
///</summary>
[JsonProperty("enabled_by_default")]
public bool? EnabledByDefault { get; set; }

///<summary>
/// The encoding of the payloads received. Set to "" to disable decoding of incoming payload.
/// , default: utf-8
///</summary>
[JsonProperty("encoding")]
public string? Encoding { get; set; }

///<summary>
/// The category of the entity.
/// , default: None
///</summary>
[JsonProperty("entity_category")]
public string? EntityCategory { get; set; }

///<summary>
/// Defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes unavailable.
///</summary>
[JsonProperty("expire_after")]
public long? ExpireAfter { get; set; }

///<summary>
/// Sends update events (which results in update of state object’s last_changed) even if the sensor’s state hasn’t changed. Useful if you want to have meaningful value graphs in history or want to create an automation that triggers on every incoming state message (not only when the sensor’s new state is different to the current one).
/// , default: false
///</summary>
[JsonProperty("force_update")]
public bool? ForceUpdate { 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>
[JsonProperty("json_attributes_template")]
public string? JsonAttributesTemplate { get; set; }

///<summary>
/// The MQTT topic subscribed to receive a JSON dictionary payload and then set as sensor attributes. Usage example can be found in MQTT sensor documentation.
///</summary>
[JsonProperty("json_attributes_topic")]
public string? JsonAttributesTopic { get; set; }

/// <summary>
///<summary>
/// Used instead of name for automatic generation of entity_id
///</summary>
[JsonProperty("object_id")]
public string? ObjectId { get; set; }

///<summary>
/// For sensors that only send on state updates (like PIRs), this variable sets a delay in seconds after which the sensor’s state will be updated back to off.
///</summary>
[JsonProperty("off_delay")]
public long? OffDelay { get; set; }

///<summary>
/// The string that represents the online state.
/// , default: online
///</summary>
[JsonProperty("payload_available")]
public string? PayloadAvailable { get; set; }

///<summary>
/// The string that represents the offline state.
/// , default: offline
///</summary>
[JsonProperty("payload_not_available")]
public string? PayloadNotAvailable { get; set; }

///<summary>
/// The string that represents the off state. It will be compared to the message in the state_topic (see value_template for details)
/// </summary>
/// , default: OFF
///</summary>
[JsonProperty("payload_off")]
public string? PayloadOff { get; set; }

/// <summary>
///<summary>
/// The string that represents the on state. It will be compared to the message in the state_topic (see value_template for details)
/// </summary>
/// , default: ON
///</summary>
[JsonProperty("payload_on")]
public string? PayloadOn { get; set; }

/// <summary>
/// Sets the <see href="https://www.home-assistant.io/integrations/binary_sensor/#device-class">class of the device</see>, changing the device state and icon that is displayed on the frontend.
/// </summary>
[JsonProperty("device_class")]
public string? DeviceClass { get; set; }
///<summary>
/// The maximum QoS level to be used when receiving messages.
/// , default: 0
///</summary>
[JsonProperty("qos")]
public long? Qos { get; set; }

///<summary>
/// The MQTT topic subscribed to receive sensor’s state.
///</summary>
[JsonProperty("state_topic")]
public string StateTopic { get; set; }

///<summary>
/// Defines a template that returns a string to be compared to payload_on/payload_off or an empty string, in which case the MQTT message will be removed. Available variables: entity_id. Remove this option when ‘payload_on’ and ‘payload_off’ are sufficient to match your payloads (i.e no pre-processing of original message is required).
///</summary>
[JsonProperty("value_template")]
public string? ValueTemplate { get; set; }
}
}
Loading

0 comments on commit 2e9d3d7

Please sign in to comment.