1.1.10 - Add MQTT zone bypass switch discovery

This commit is contained in:
Ryan Wagoner 2021-07-20 23:28:10 -04:00
parent 37aed0e891
commit 92012fc0b7
4 changed files with 32 additions and 3 deletions

View file

@ -275,6 +275,21 @@ namespace OmniLinkBridge.MQTT
return ret;
}
public static Switch ToConfigSwitch(this clsZone zone)
{
Switch ret = new Switch
{
unique_id = $"{Global.mqtt_prefix}zone{zone.Number}switch",
name = $"{Global.mqtt_discovery_name_prefix}{zone.Name} Bypass",
state_topic = zone.ToTopic(Topic.state),
command_topic = zone.ToTopic(Topic.command),
payload_off = "restore",
payload_on = "bypass",
value_template = "{% if value == 'bypassed' %} bypass {%- else -%} restore {%- endif %}"
};
return ret;
}
public static BinarySensor ToConfig(this clsZone zone)
{
BinarySensor ret = new BinarySensor

View file

@ -1,7 +1,18 @@
namespace OmniLinkBridge.MQTT
using Newtonsoft.Json;
namespace OmniLinkBridge.MQTT
{
public class Switch : Device
{
public string command_topic { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string payload_off { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string payload_on { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string value_template { get; set; }
}
}

View file

@ -277,6 +277,7 @@ namespace OmniLinkBridge.Modules
{
PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", null);
continue;
@ -286,6 +287,8 @@ namespace OmniLinkBridge.Modules
JsonConvert.SerializeObject(zone.ToConfig()));
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config",
JsonConvert.SerializeObject(zone.ToConfigSensor()));
PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config",
JsonConvert.SerializeObject(zone.ToConfigSwitch()));
if (zone.IsTemperatureZone())
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config",

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.9.0")]
[assembly: AssemblyFileVersion("1.1.9.0")]
[assembly: AssemblyVersion("1.1.10.0")]
[assembly: AssemblyFileVersion("1.1.10.0")]