Skip to content

Commit

Permalink
1.1.11 - Add MQTT thermostat humidify and dehumidify discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
rwagoner committed Nov 5, 2021
1 parent a8d965e commit 2f652f7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
26 changes: 26 additions & 0 deletions OmniLinkBridge/MQTT/MappingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,32 @@ public static Sensor ToConfigTemp(this clsThermostat thermostat, enuTempFormat f
return ret;
}

public static Number ToConfigHumidify(this clsThermostat thermostat)
{
Number ret = new Number
{
unique_id = $"{Global.mqtt_prefix}thermostat{thermostat.Number}humidify",
name = $"{Global.mqtt_discovery_name_prefix}{thermostat.Name} Humidify",
icon = "mdi:water-percent",
state_topic = thermostat.ToTopic(Topic.humidify_state),
command_topic = thermostat.ToTopic(Topic.humidify_command),
};
return ret;
}

public static Number ToConfigDehumidify(this clsThermostat thermostat)
{
Number ret = new Number
{
unique_id = $"{Global.mqtt_prefix}thermostat{thermostat.Number}dehumidify",
name = $"{Global.mqtt_discovery_name_prefix}{thermostat.Name} Dehumidify",
icon = "mdi:water-percent",
state_topic = thermostat.ToTopic(Topic.dehumidify_state),
command_topic = thermostat.ToTopic(Topic.dehumidify_command),
};
return ret;
}

public static Sensor ToConfigHumidity(this clsThermostat thermostat)
{
Sensor ret = new Sensor
Expand Down
12 changes: 12 additions & 0 deletions OmniLinkBridge/MQTT/Number.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace OmniLinkBridge.MQTT
{
public class Number : Device
{
public string command_topic { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string icon { get; set; }
}
}
8 changes: 7 additions & 1 deletion OmniLinkBridge/Modules/MQTTModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public BinarySensor SystemTroubleConfig(string type, string name)
return new BinarySensor
{
unique_id = $"{Global.mqtt_prefix}system{type}",
name = $"{Global.mqtt_discovery_name_prefix} System {name}",
name = $"{Global.mqtt_discovery_name_prefix}System {name}",
state_topic = SystemTroubleTopic(type),
device_class = BinarySensor.DeviceClass.problem
};
Expand Down Expand Up @@ -345,6 +345,8 @@ private void PublishThermostats()
{
PublishAsync(thermostat.ToTopic(Topic.name), null);
PublishAsync($"{Global.mqtt_discovery_prefix}/climate/{Global.mqtt_prefix}/thermostat{i}/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/number/{Global.mqtt_prefix}/thermostat{i}humidify/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/number/{Global.mqtt_prefix}/thermostat{i}dehumidify/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/thermostat{i}temp/config", null);
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/thermostat{i}humidity/config", null);
continue;
Expand All @@ -355,6 +357,10 @@ private void PublishThermostats()
PublishAsync(thermostat.ToTopic(Topic.name), thermostat.Name);
PublishAsync($"{Global.mqtt_discovery_prefix}/climate/{Global.mqtt_prefix}/thermostat{i}/config",
JsonConvert.SerializeObject(thermostat.ToConfig(OmniLink.Controller.TempFormat)));
PublishAsync($"{Global.mqtt_discovery_prefix}/number/{Global.mqtt_prefix}/thermostat{i}humidify/config",
JsonConvert.SerializeObject(thermostat.ToConfigHumidify()));
PublishAsync($"{Global.mqtt_discovery_prefix}/number/{Global.mqtt_prefix}/thermostat{i}dehumidify/config",
JsonConvert.SerializeObject(thermostat.ToConfigDehumidify()));
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/thermostat{i}temp/config",
JsonConvert.SerializeObject(thermostat.ToConfigTemp(OmniLink.Controller.TempFormat)));
PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/thermostat{i}humidity/config",
Expand Down
1 change: 1 addition & 0 deletions OmniLinkBridge/OmniLinkBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<Compile Include="MQTT\DeviceRegistry.cs" />
<Compile Include="MQTT\MessageCommands.cs" />
<Compile Include="MQTT\MessageProcessor.cs" />
<Compile Include="MQTT\Number.cs" />
<Compile Include="MQTT\OverrideZone.cs" />
<Compile Include="MQTT\Switch.cs" />
<Compile Include="MQTT\Light.cs" />
Expand Down
6 changes: 3 additions & 3 deletions OmniLinkBridge/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Excalibur Partners, LLC")]
[assembly: AssemblyProduct("OmniLinkBridge")]
[assembly: AssemblyCopyright("Copyright © Excalibur Partners, LLC 2020")]
[assembly: AssemblyCopyright("Copyright © Excalibur Partners, LLC 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// 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.10.0")]
[assembly: AssemblyFileVersion("1.1.10.0")]
[assembly: AssemblyVersion("1.1.11.0")]
[assembly: AssemblyFileVersion("1.1.11.0")]

0 comments on commit 2f652f7

Please sign in to comment.