-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.1.14 - Improve MQTT unit, output and flag capabilities
- Loading branch information
Showing
41 changed files
with
386 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using HAI_Shared; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniLinkBridge.MQTT | ||
{ | ||
public static class Extensions | ||
{ | ||
public static AreaCommandCode ToCommandCode(this string payload, bool supportValidate = false) | ||
{ | ||
string[] payloads = payload.Split(','); | ||
int code = 0; | ||
|
||
AreaCommandCode ret = new AreaCommandCode() | ||
{ | ||
Command = payloads[0] | ||
}; | ||
|
||
if (payload.Length == 1) | ||
return ret; | ||
|
||
if (payloads.Length == 2) | ||
{ | ||
ret.Success = int.TryParse(payloads[1], out code); | ||
} | ||
else if (supportValidate && payloads.Length == 3) | ||
{ | ||
if (string.Compare(payloads[1], "validate", true) == 0) | ||
{ | ||
ret.Validate = true; | ||
ret.Success = int.TryParse(payloads[2], out code); | ||
} | ||
else | ||
ret.Success = false; | ||
} | ||
|
||
ret.Code = code; | ||
return ret; | ||
} | ||
|
||
public static UnitType ToUnitType(this clsUnit unit) | ||
{ | ||
Global.mqtt_discovery_override_unit.TryGetValue(unit.Number, out OverrideUnit override_unit); | ||
|
||
if (unit.Type == enuOL2UnitType.Output) | ||
return UnitType.@switch; | ||
|
||
if (unit.Type == enuOL2UnitType.Flag) | ||
{ | ||
if (override_unit != null && override_unit.type == UnitType.number) | ||
return UnitType.number; | ||
|
||
return UnitType.@switch; | ||
} | ||
|
||
if (override_unit != null && override_unit.type == UnitType.@switch) | ||
return UnitType.@switch; | ||
|
||
return UnitType.light; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/Alarm.cs → OmniLinkBridge/MQTT/HomeAssistant/Alarm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/BinarySensor.cs → ...Bridge/MQTT/HomeAssistant/BinarySensor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/Climate.cs → OmniLinkBridge/MQTT/HomeAssistant/Climate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/DeviceRegistry.cs → ...idge/MQTT/HomeAssistant/DeviceRegistry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.HomeAssistant | ||
{ | ||
public class DeviceRegistry | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/Light.cs → OmniLinkBridge/MQTT/HomeAssistant/Light.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.HomeAssistant | ||
{ | ||
public class Light : Device | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace OmniLinkBridge.MQTT.HomeAssistant | ||
{ | ||
public class Number : Device | ||
{ | ||
public string command_topic { get; set; } | ||
|
||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] | ||
public string icon { get; set; } | ||
|
||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] | ||
public int? min { get; set; } | ||
|
||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] | ||
public int? max { get; set; } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/Sensor.cs → OmniLinkBridge/MQTT/HomeAssistant/Sensor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/Switch.cs → OmniLinkBridge/MQTT/HomeAssistant/Switch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OmniLinkBridge.MQTT | ||
{ | ||
public class OverrideUnit | ||
{ | ||
public UnitType type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/AlarmCommands.cs → OmniLinkBridge/MQTT/Parser/AlarmCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum AlarmCommands | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/AreaCommands.cs → OmniLinkBridge/MQTT/Parser/AreaCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum AreaCommands | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/CommandTypes.cs → OmniLinkBridge/MQTT/Parser/CommandTypes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum CommandTypes | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/MessageCommands.cs → ...LinkBridge/MQTT/Parser/MessageCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum MessageCommands | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/UnitCommands.cs → OmniLinkBridge/MQTT/Parser/UnitCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum UnitCommands | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
OmniLinkBridge/MQTT/ZoneCommands.cs → OmniLinkBridge/MQTT/Parser/ZoneCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace OmniLinkBridge.MQTT | ||
namespace OmniLinkBridge.MQTT.Parser | ||
{ | ||
enum ZoneCommands | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace OmniLinkBridge.MQTT | ||
{ | ||
public enum UnitType | ||
{ | ||
@switch, | ||
light, | ||
number | ||
} | ||
} |
Oops, something went wrong.