diff --git a/OmniLinkBridge/MQTT/Device.cs b/OmniLinkBridge/MQTT/Device.cs index 319b986..6496731 100644 --- a/OmniLinkBridge/MQTT/Device.cs +++ b/OmniLinkBridge/MQTT/Device.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,6 +11,7 @@ namespace OmniLinkBridge.MQTT { public string name { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string state_topic { get; set; } public string availability_topic { get; set; } = $"{Global.mqtt_prefix}/status"; diff --git a/OmniLinkBridge/Modules/MQTTModule.cs b/OmniLinkBridge/Modules/MQTTModule.cs index 324ef41..299cfed 100644 --- a/OmniLinkBridge/Modules/MQTTModule.cs +++ b/OmniLinkBridge/Modules/MQTTModule.cs @@ -474,7 +474,9 @@ namespace OmniLinkBridge.Modules private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e) { - if(!e.EventTimer) + // Ignore events fired by thermostat polling and when temperature is invalid + // An invalid temperature can occur when a Zigbee thermostat is unreachable + if(!e.EventTimer && e.Thermostat.Temp > 0) PublishThermostatState(e.Thermostat); } diff --git a/OmniLinkBridge/Modules/WebServiceModule.cs b/OmniLinkBridge/Modules/WebServiceModule.cs index 7f7042d..035f594 100644 --- a/OmniLinkBridge/Modules/WebServiceModule.cs +++ b/OmniLinkBridge/Modules/WebServiceModule.cs @@ -89,7 +89,9 @@ namespace OmniLinkBridge private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e) { - if(!e.EventTimer) + // Ignore events fired by thermostat polling and when temperature is invalid + // An invalid temperature can occur when a Zigbee thermostat is unreachable + if (!e.EventTimer && e.Thermostat.Temp > 0) WebNotification.Send("thermostat", JsonConvert.SerializeObject(e.Thermostat.ToContract())); } } diff --git a/OmniLinkBridge/OmniLink/ThermostatStatusEventArgs.cs b/OmniLinkBridge/OmniLink/ThermostatStatusEventArgs.cs index 5372e22..4abcfff 100644 --- a/OmniLinkBridge/OmniLink/ThermostatStatusEventArgs.cs +++ b/OmniLinkBridge/OmniLink/ThermostatStatusEventArgs.cs @@ -7,6 +7,10 @@ namespace OmniLinkBridge.OmniLink { public ushort ID { get; set; } public clsThermostat Thermostat { get; set; } + + /// + /// Set to true when fired by thermostat polling + /// public bool EventTimer { get; set; } } } diff --git a/OmniLinkBridge/OmniLinkBridge.ini b/OmniLinkBridge/OmniLinkBridge.ini index 94a4387..d5d1e5a 100644 --- a/OmniLinkBridge/OmniLinkBridge.ini +++ b/OmniLinkBridge/OmniLinkBridge.ini @@ -5,8 +5,8 @@ controller_key1 = 00-00-00-00-00-00-00-00 controller_key2 = 00-00-00-00-00-00-00-00 # Controller Time Sync (yes/no) -# time_check is interval in minutes to check controller time -# time_adj is the drift in seconds to allow before an adjustment is made +# time_interval is interval in minutes to check controller time +# time_drift is the drift in seconds to allow before an adjustment is made time_sync = yes time_interval = 60 time_drift = 10 diff --git a/README.md b/README.md index 3676a81..7f16228 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ You can use docker to build an image from git or download the [binary here](http - cp OmniLinkBridge/OmniLinkBridge.ini /opt/omnilink-bridge - vim /opt/omnilink-bridge/OmniLinkBridge.ini 3. Start docker container - - docker run -d --name="omnilink-bridge" -v /opt/omnilink-bridge:/config -v /etc/localtime:/etc/localtime:ro --net=host --restart unless-stopped omnilink-bridge + - docker run -d --name="omnilink-bridge" -v /opt/omnilink-bridge:/config -v /etc/localtime:/etc/localtime:ro --net=host --restart always omnilink-bridge 4. Verify connectivity by looking at logs - docker container logs omnilink-bridge @@ -90,11 +90,9 @@ This module will also publish discovery topics for Home Assistant to auto config - [Add night arm mode to MQTT alarm control panel](https://github.com/home-assistant/home-assistant/pull/17390/) ``` -mkdir -p custom_components/climate -wget https://raw.githubusercontent.com/home-assistant/home-assistant/dcfcca77d72b0c35cda9950a69f621b4e8cff81b/homeassistant/components/climate/mqtt.py -O custom_components/climate/mqtt.py - -mkdir -p custom_components/alarm_control_panel -wget https://raw.githubusercontent.com/home-assistant/home-assistant/fa2510f58b40cfea2974530658ee011d984db6c7/homeassistant/components/alarm_control_panel/mqtt.py -O custom_components/alarm_control_panel/mqtt.py +mkdir -p custom_components/mqtt +wget https://raw.githubusercontent.com/home-assistant/home-assistant/dcfcca77d72b0c35cda9950a69f621b4e8cff81b/homeassistant/components/climate/mqtt.py -O custom_components/mqtt/climate.py +wget https://raw.githubusercontent.com/home-assistant/home-assistant/fa2510f58b40cfea2974530658ee011d984db6c7/homeassistant/components/alarm_control_panel/mqtt.py -O custom_components/mqtt/alarm_control_panel.py ``` ### Areas @@ -199,7 +197,7 @@ Version 1.1.2 - 2018-10-23 - Add detailed zone sensor and thermostat humidity sensor - Add prefix for MQTT discovery entity name - Request zone status update on area status change - + Version 1.1.1 - 2018-10-18 - Added docker support - Save subscriptions on change