[NF] Flex4Grid Plugin for Zway-Bot beginning
This commit is contained in:
parent
8771a3ce89
commit
81737d5d3a
14
Zway-Bot.sln
14
Zway-Bot.sln
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26730.16
|
VisualStudioVersion = 15.0.27004.2010
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zway-Bot", "Zway-Bot\Zway-Bot.csproj", "{AEF8059F-8AEF-45C7-85C4-318C8F797900}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zway-Bot", "Zway-Bot\Zway-Bot.csproj", "{AEF8059F-8AEF-45C7-85C4-318C8F797900}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zway", "..\Zway\Zway\Zway.c
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto", "..\Utils\IoT\Connector\Data\Mosquitto\ConnectorDataMosquitto.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -27,6 +31,14 @@ Global
|
|||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
91
Zway-Bot/Moduls/Flex4Grid.cs
Normal file
91
Zway-Bot/Moduls/Flex4Grid.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using BlubbFish.IoT.Zway;
|
||||||
|
using BlubbFish.IoT.Zway.Devices.CommandClasses;
|
||||||
|
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.Utils;
|
||||||
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace ZwayBot.Moduls {
|
||||||
|
class Flex4Grid : AModul, IDisposable {
|
||||||
|
private ADataBackend mqtt;
|
||||||
|
|
||||||
|
public override event ModulEvent Update;
|
||||||
|
|
||||||
|
public Flex4Grid(ZwayController zway, InIReader settings) : base(zway, settings) {
|
||||||
|
this.mqtt = ADataBackend.GetInstance(this.ini.GetSection("settings"));
|
||||||
|
this.ParseIni();
|
||||||
|
this.mqtt.MessageIncomming += this.Mqtt_MessageIncomming;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseIni() {
|
||||||
|
if (this.ini.GetValue("zway", "devices") != null) {
|
||||||
|
foreach (String device in this.ini.GetValue("zway", "devices").Split(',')) {
|
||||||
|
Int32 deviceid = Int32.Parse(device);
|
||||||
|
if (this.zw.Devices.ContainsKey(deviceid) && this.zw.Devices[deviceid].Instances.ContainsKey(0)) {
|
||||||
|
if(this.zw.Devices[deviceid].Instances[0].CommandClasses.ContainsKey(37)) { //SwitchBinary
|
||||||
|
this.zw.Devices[deviceid].Instances[0].CommandClasses[37].Update += this.SwitchBinaryUpdate;
|
||||||
|
}
|
||||||
|
if (this.zw.Devices[deviceid].Instances[0].CommandClasses.ContainsKey(49) &&
|
||||||
|
((Sensormultilevel)this.zw.Devices[deviceid].Instances[0].CommandClasses[49]).Sub.ContainsKey(4)) { //SensorMultilevel
|
||||||
|
((Sensormultilevel)this.zw.Devices[deviceid].Instances[0].CommandClasses[49]).Sub[4].Update += this.SensorMultilevelUpdate;
|
||||||
|
}
|
||||||
|
if (this.zw.Devices[deviceid].Instances[0].CommandClasses.ContainsKey(50) &&
|
||||||
|
((Meter)this.zw.Devices[deviceid].Instances[0].CommandClasses[50]).Sub.ContainsKey(0)) { //Meter
|
||||||
|
((Meter)this.zw.Devices[deviceid].Instances[0].CommandClasses[50]).Sub[0].Update += this.MeterUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Mqtt_MessageIncomming(Object sender, MqttEventArgs e) {
|
||||||
|
JsonData message;
|
||||||
|
String topic = e.Topic;
|
||||||
|
try {
|
||||||
|
if (e.Message.StartsWith("{")) {
|
||||||
|
message = JsonMapper.ToObject(e.Message);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MeterUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
Metersub device = (Metersub)sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SensorMultilevelUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
Sensormultilevelsub device = (Sensormultilevelsub)sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SwitchBinaryUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
Switchbinary device = (Switchbinary)sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Support
|
||||||
|
private Boolean disposedValue = false;
|
||||||
|
|
||||||
|
protected virtual void Dispose(Boolean disposing) {
|
||||||
|
if (!this.disposedValue) {
|
||||||
|
if (disposing) {
|
||||||
|
this.mqtt.Dispose();
|
||||||
|
}
|
||||||
|
this.disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~Flex4Grid() {
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose() {
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,9 @@
|
|||||||
<StartupObject>ZwayBot.Program</StartupObject>
|
<StartupObject>ZwayBot.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
@ -49,11 +52,20 @@
|
|||||||
<Compile Include="Moduls\AModul.cs" />
|
<Compile Include="Moduls\AModul.cs" />
|
||||||
<Compile Include="Moduls\CronJob.cs" />
|
<Compile Include="Moduls\CronJob.cs" />
|
||||||
<Compile Include="Helper.cs" />
|
<Compile Include="Helper.cs" />
|
||||||
|
<Compile Include="Moduls\Flex4Grid.cs" />
|
||||||
<Compile Include="Moduls\Overtaker.cs" />
|
<Compile Include="Moduls\Overtaker.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Connector\Data\Mosquitto\ConnectorDataMosquitto.csproj">
|
||||||
|
<Project>{39235fad-ba9d-4b51-82fc-6969967beae9}</Project>
|
||||||
|
<Name>ConnectorDataMosquitto</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
|
||||||
|
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
||||||
|
<Name>Utils-IoT</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
||||||
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||||
<Name>Utils</Name>
|
<Name>Utils</Name>
|
||||||
@ -63,5 +75,8 @@
|
|||||||
<Name>Zway</Name>
|
<Name>Zway</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
4
Zway-Bot/packages.config
Normal file
4
Zway-Bot/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="LitJson" version="0.9.0" targetFramework="net461" />
|
||||||
|
</packages>
|
Loading…
Reference in New Issue
Block a user