From a8d965eb046f274ea369da9a43ed8e75c69afc5e Mon Sep 17 00:00:00 2001 From: Ryan Wagoner Date: Thu, 4 Nov 2021 20:34:13 -0400 Subject: [PATCH] Add thermostat emergency heat and fix hold documentation --- OmniLinkBridge.sql | 4 ++-- OmniLinkBridge/MQTT/Climate.cs | 1 + OmniLinkBridge/MQTT/MappingExtensions.cs | 18 +++++++++++++++++- OmniLinkBridge/MQTT/Topic.cs | 1 + OmniLinkBridge/Modules/MQTTModule.cs | 3 ++- OmniLinkBridge/OmniLinkBridge.csproj | 2 +- OmniLinkBridgeTest/OmniLinkBridgeTest.csproj | 4 ++-- README.md | 9 +++++++-- 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/OmniLinkBridge.sql b/OmniLinkBridge.sql index 7544354..b4c9f7f 100644 --- a/OmniLinkBridge.sql +++ b/OmniLinkBridge.sql @@ -85,9 +85,9 @@ CREATE TABLE IF NOT EXISTS `log_thermostats` ( `humidity` smallint(6) NOT NULL, `humidify` smallint(6) NOT NULL, `dehumidify` smallint(6) NOT NULL, - `mode` varchar(5) NOT NULL, + `mode` varchar(14) NOT NULL, `fan` varchar(5) NOT NULL, - `hold` varchar(5) NOT NULL, + `hold` varchar(8) NOT NULL, PRIMARY KEY (`log_tstat_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; diff --git a/OmniLinkBridge/MQTT/Climate.cs b/OmniLinkBridge/MQTT/Climate.cs index eb50b21..b3aca71 100644 --- a/OmniLinkBridge/MQTT/Climate.cs +++ b/OmniLinkBridge/MQTT/Climate.cs @@ -26,5 +26,6 @@ namespace OmniLinkBridge.MQTT public string hold_state_topic { get; set; } public string hold_command_topic { get; set; } + public List hold_modes { get; set; } = new List(new string[] { "on", "vacation" }); } } diff --git a/OmniLinkBridge/MQTT/MappingExtensions.cs b/OmniLinkBridge/MQTT/MappingExtensions.cs index bf85342..942508d 100644 --- a/OmniLinkBridge/MQTT/MappingExtensions.cs +++ b/OmniLinkBridge/MQTT/MappingExtensions.cs @@ -478,7 +478,7 @@ namespace OmniLinkBridge.MQTT ret.temperature_high_state_topic = thermostat.ToTopic(Topic.temperature_cool_state); ret.temperature_high_command_topic = thermostat.ToTopic(Topic.temperature_cool_command); - ret.mode_state_topic = thermostat.ToTopic(Topic.mode_state); + ret.mode_state_topic = thermostat.ToTopic(Topic.mode_basic_state); ret.mode_command_topic = thermostat.ToTopic(Topic.mode_command); ret.fan_mode_state_topic = thermostat.ToTopic(Topic.fan_mode_state); @@ -499,6 +499,22 @@ namespace OmniLinkBridge.MQTT return "idle"; } + public static string ToModeState(this clsThermostat thermostat) + { + if (thermostat.Mode == enuThermostatMode.E_Heat) + return "e_heat"; + else + return thermostat.ModeText().ToLower(); + } + + public static string ToModeBasicState(this clsThermostat thermostat) + { + if (thermostat.Mode == enuThermostatMode.E_Heat) + return "heat"; + else + return thermostat.ModeText().ToLower(); + } + public static string ToTopic(this clsButton button, Topic topic) { return $"{Global.mqtt_prefix}/button{button.Number}/{topic}"; diff --git a/OmniLinkBridge/MQTT/Topic.cs b/OmniLinkBridge/MQTT/Topic.cs index 793bff7..48016d6 100644 --- a/OmniLinkBridge/MQTT/Topic.cs +++ b/OmniLinkBridge/MQTT/Topic.cs @@ -24,6 +24,7 @@ dehumidify_state, dehumidify_command, mode_state, + mode_basic_state, mode_command, fan_mode_state, fan_mode_command, diff --git a/OmniLinkBridge/Modules/MQTTModule.cs b/OmniLinkBridge/Modules/MQTTModule.cs index 2f9da5d..bb36444 100644 --- a/OmniLinkBridge/Modules/MQTTModule.cs +++ b/OmniLinkBridge/Modules/MQTTModule.cs @@ -535,7 +535,8 @@ namespace OmniLinkBridge.Modules PublishAsync(thermostat.ToTopic(Topic.temperature_cool_state), thermostat.CoolSetpointText()); PublishAsync(thermostat.ToTopic(Topic.humidify_state), thermostat.HumidifySetpointText()); PublishAsync(thermostat.ToTopic(Topic.dehumidify_state), thermostat.DehumidifySetpointText()); - PublishAsync(thermostat.ToTopic(Topic.mode_state), thermostat.ModeText().ToLower()); + PublishAsync(thermostat.ToTopic(Topic.mode_state), thermostat.ToModeState()); + PublishAsync(thermostat.ToTopic(Topic.mode_basic_state), thermostat.ToModeBasicState()); PublishAsync(thermostat.ToTopic(Topic.fan_mode_state), thermostat.FanModeText().ToLower()); PublishAsync(thermostat.ToTopic(Topic.hold_state), thermostat.HoldStatusText().ToLower()); } diff --git a/OmniLinkBridge/OmniLinkBridge.csproj b/OmniLinkBridge/OmniLinkBridge.csproj index 6de1c37..51b3f46 100644 --- a/OmniLinkBridge/OmniLinkBridge.csproj +++ b/OmniLinkBridge/OmniLinkBridge.csproj @@ -173,7 +173,7 @@ 4.5.0 - 3.0.16 + 3.0.17 13.0.1 diff --git a/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj b/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj index 07a0fa3..795bf81 100644 --- a/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj +++ b/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj @@ -59,10 +59,10 @@ - 2.0.0 + 2.2.7 - 2.0.0 + 2.2.7 diff --git a/README.md b/README.md index f40c4e3..1a4e169 100644 --- a/README.md +++ b/README.md @@ -253,15 +253,20 @@ int Setpoint in relative humidity SUB omnilink/thermostatX/mode_state PUB omnilink/thermostatX/mode_command +string auto, off, cool, heat, e_heat + +SUB omnilink/thermostatX/mode_basic_state string auto, off, cool, heat SUB omnilink/thermostatX/fan_mode_state PUB omnilink/thermostatX/fan_mode_command string auto, on, cycle -SUB omnilink/thermostatX/hold_state +SUB omnilink/thermostatX/hold_state +string off, on, vacation + PUB omnilink/thermostatX/hold_command -string off, hold +string off, on ``` ### Buttons