[DW] Alarmsensor added
This commit is contained in:
parent
beea6c1ee0
commit
8dd8605d73
62
Zway/Devices/CommandClasses/AlarmSensor.cs
Normal file
62
Zway/Devices/CommandClasses/AlarmSensor.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.RegularExpressions;
|
||||
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
||||
using BlubbFish.IoT.Zway.Events;
|
||||
using BlubbFish.IoT.Zway.Interfaces;
|
||||
using BlubbFish.IoT.Zway.lib;
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||
/// <summary>
|
||||
/// 50 = Meter
|
||||
/// </summary>
|
||||
public class Alarmsensor : ACommandClass {
|
||||
public override event UpdatedValue Update;
|
||||
|
||||
public Alarmsensor(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||
this.HasSub = true;
|
||||
this.InitComplex(json);
|
||||
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||
item.Value.Update += this.DeviceUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||
this.Update?.Invoke(this, e);
|
||||
}
|
||||
|
||||
internal override void SetUpdate(JsonData json, Match match) {
|
||||
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||
if (this.Sub.ContainsKey(subid)) {
|
||||
this.Sub[subid].SetUpdate(json, match);
|
||||
}
|
||||
} else {
|
||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitComplex(JsonData json) {
|
||||
if (json.Keys.Contains("data")) {
|
||||
JsonData data = json["data"];
|
||||
Dictionary<Int32, ACommandClass> subs = new Dictionary<Int32, ACommandClass>();
|
||||
foreach (String item in data.Keys) {
|
||||
if (Int32.TryParse(item, out Int32 subid) &&
|
||||
data[item].Keys.Contains("srcId") &&
|
||||
data[item].Keys.Contains("sensorState") &&
|
||||
data[item].Keys.Contains("sensorTime") &&
|
||||
data[item].Keys.Contains("typeString")) {
|
||||
subs.Add(subid, new Alarmsensorsub(data[item], new Tuple<Int32, Int32, Classes, Int32>(this.DeviceId, this.Instance, this.Commandclass, subid), this.http, this.Polling));
|
||||
}
|
||||
}
|
||||
this.Sub = new ReadOnlyDictionary<Int32, ACommandClass>(subs);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Poll() => this.PollSubGlobal();
|
||||
|
||||
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using BlubbFish.IoT.Zway.Events;
|
||||
using BlubbFish.IoT.Zway.Interfaces;
|
||||
using BlubbFish.IoT.Zway.lib;
|
||||
using LitJson;
|
||||
|
||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||
public class Alarmsensorsub : ACommandClass {
|
||||
public override event UpdatedValue Update;
|
||||
|
||||
public Int32 Source { get; private set; }
|
||||
public Int32 Level { get; private set; }
|
||||
public Int32 Time { get; private set; }
|
||||
public String Type { get; private set; }
|
||||
|
||||
public Alarmsensorsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||
this.IsSub = true;
|
||||
InitComplex(json);
|
||||
}
|
||||
|
||||
private void InitComplex(JsonData json) {
|
||||
if (json.Keys.Contains("srcId") && json["srcId"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("sensorState") && json["sensorState"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("sensorTime") && json["sensorTime"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("typeString") && json["typeString"].Keys.Contains("value")) {
|
||||
this.Source = Int32.Parse(json["srcId"]["value"].ToString());
|
||||
this.Level = Int32.Parse(json["sensorState"]["value"].ToString());
|
||||
this.Time = Int32.Parse(json["sensorTime"]["value"].ToString());
|
||||
this.Type = json["typeString"]["value"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void SetUpdate(JsonData json, Match match) {
|
||||
if (json.Keys.Contains("srcId") && json["srcId"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("sensorState") && json["sensorState"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("sensorTime") && json["sensorTime"].Keys.Contains("value") &&
|
||||
json.Keys.Contains("typeString") && json["typeString"].Keys.Contains("value") &&
|
||||
this.CheckSetUpdateTime(json)) {
|
||||
this.Source = Int32.Parse(json["srcId"]["value"].ToString());
|
||||
this.Level = Int32.Parse(json["sensorState"]["value"].ToString());
|
||||
this.Time = Int32.Parse(json["sensorTime"]["value"].ToString());
|
||||
this.Type = json["typeString"]["value"].ToString();
|
||||
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32, Int32, String>(this.Source, this.Level, this.Time, this.Type), this.LastUpdate, this));
|
||||
}
|
||||
}
|
||||
|
||||
public override String ToString() {
|
||||
return "AlarmSensor " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Source + " " + this.Level + " " + this.Time + " " + this.Type;
|
||||
}
|
||||
|
||||
internal override void Poll() => this.PollNone();
|
||||
|
||||
public override Dictionary<String, Object> ToDictionary() {
|
||||
return new Dictionary<String, Object> {
|
||||
{ "Source", this.Source },
|
||||
{ "Level", this.Level },
|
||||
{ "Time", this.Time },
|
||||
{ "Type", this.Type }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -36,8 +36,7 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
||||
Proprietary = 136,
|
||||
MultiChannelAssociation = 142,
|
||||
MultiCmd = 143,
|
||||
Security = 152,
|
||||
AlarmSensor = 156 //
|
||||
Security = 152
|
||||
}
|
||||
|
||||
public enum Classes : Int32 {
|
||||
@ -54,7 +53,8 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
||||
Alarm = 113,
|
||||
Battery = 128,
|
||||
Wakeup = 132,
|
||||
Indicator = 135
|
||||
Indicator = 135,
|
||||
AlarmSensor = 156
|
||||
}
|
||||
|
||||
public Int32 DeviceId { get; }
|
||||
|
@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BlubbFish.IoT.Zway</RootNamespace>
|
||||
<AssemblyName>Zway</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -31,7 +32,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\IoT-Bot\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
||||
<HintPath>..\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -46,11 +47,13 @@
|
||||
<Compile Include="Devices\CommandClasses\Alarm.cs" />
|
||||
<Compile Include="Devices\CommandClasses\Battery.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\Configurationsub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\Alarmsensorsub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\SceneControllerConfSub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\SensorBinarySub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\ThermostatSetPointSub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\Configuration.cs" />
|
||||
<Compile Include="Devices\CommandClasses\Indicator.cs" />
|
||||
<Compile Include="Devices\CommandClasses\AlarmSensor.cs" />
|
||||
<Compile Include="Devices\CommandClasses\Meter.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\MeterSub.cs" />
|
||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\SensorMultilevelSub.cs" />
|
||||
@ -76,6 +79,5 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="LitJson" version="0.9.0" targetFramework="net461" />
|
||||
<package id="LitJson" version="0.9.0" targetFramework="net471" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user