- Fix compatibility with Home Assistant 0.95.4 MQTT extra keys

- Don't publish invalid thermostat temperatures
This commit is contained in:
Ryan Wagoner 2019-10-27 18:58:55 -04:00
parent a9c52b433f
commit 177dda4c1a
6 changed files with 20 additions and 12 deletions

View file

@ -1,4 +1,5 @@
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -10,6 +11,7 @@ namespace OmniLinkBridge.MQTT
{ {
public string name { get; set; } public string name { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string state_topic { get; set; } public string state_topic { get; set; }
public string availability_topic { get; set; } = $"{Global.mqtt_prefix}/status"; public string availability_topic { get; set; } = $"{Global.mqtt_prefix}/status";

View file

@ -474,7 +474,9 @@ namespace OmniLinkBridge.Modules
private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e) 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); PublishThermostatState(e.Thermostat);
} }

View file

@ -89,7 +89,9 @@ namespace OmniLinkBridge
private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e) 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())); WebNotification.Send("thermostat", JsonConvert.SerializeObject(e.Thermostat.ToContract()));
} }
} }

View file

@ -7,6 +7,10 @@ namespace OmniLinkBridge.OmniLink
{ {
public ushort ID { get; set; } public ushort ID { get; set; }
public clsThermostat Thermostat { get; set; } public clsThermostat Thermostat { get; set; }
/// <summary>
/// Set to true when fired by thermostat polling
/// </summary>
public bool EventTimer { get; set; } public bool EventTimer { get; set; }
} }
} }

View file

@ -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_key2 = 00-00-00-00-00-00-00-00
# Controller Time Sync (yes/no) # Controller Time Sync (yes/no)
# time_check is interval in minutes to check controller time # time_interval is interval in minutes to check controller time
# time_adj is the drift in seconds to allow before an adjustment is made # time_drift is the drift in seconds to allow before an adjustment is made
time_sync = yes time_sync = yes
time_interval = 60 time_interval = 60
time_drift = 10 time_drift = 10

View file

@ -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 - cp OmniLinkBridge/OmniLinkBridge.ini /opt/omnilink-bridge
- vim /opt/omnilink-bridge/OmniLinkBridge.ini - vim /opt/omnilink-bridge/OmniLinkBridge.ini
3. Start docker container 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 4. Verify connectivity by looking at logs
- docker container logs omnilink-bridge - 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/) - [Add night arm mode to MQTT alarm control panel](https://github.com/home-assistant/home-assistant/pull/17390/)
``` ```
mkdir -p custom_components/climate mkdir -p custom_components/mqtt
wget https://raw.githubusercontent.com/home-assistant/home-assistant/dcfcca77d72b0c35cda9950a69f621b4e8cff81b/homeassistant/components/climate/mqtt.py -O custom_components/climate/mqtt.py 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
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
``` ```
### Areas ### Areas
@ -199,7 +197,7 @@ Version 1.1.2 - 2018-10-23
- Add detailed zone sensor and thermostat humidity sensor - Add detailed zone sensor and thermostat humidity sensor
- Add prefix for MQTT discovery entity name - Add prefix for MQTT discovery entity name
- Request zone status update on area status change - Request zone status update on area status change
Version 1.1.1 - 2018-10-18 Version 1.1.1 - 2018-10-18
- Added docker support - Added docker support
- Save subscriptions on change - Save subscriptions on change