Skip to content

Commit

Permalink
Fixed #363 and #360
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Feb 5, 2019
1 parent 18dbd4c commit 98fece6
Show file tree
Hide file tree
Showing 33 changed files with 69 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: csharp
mono: latest
mono: 4.6.2
dist: xenial
solution: HomeGenie_Linux/HomeGenie_Linux.sln
before_install:
Expand Down
Binary file modified BaseFiles/Common/homegenie_factory_config.zip
Binary file not shown.
132 changes: 60 additions & 72 deletions BaseFiles/Common/programs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,9 @@ var STATUS_DISARMED = "Disarmed";
var STATUS_ARMED_AWAY = "Away";
var STATUS_ARMED_HOME = "Home";

Program.RaiseEvent("HomeGenie.SecurityArmed", STATUS_DISARMED, "Security System");
Program.Parameter("HomeGenie.SecurityTriggered").Value = "0";
Program.Parameter("Status.Level").Value = "0";
//Program.RaiseEvent("HomeGenie.SecurityArmed", STATUS_DISARMED, "Security System");
//Program.Parameter("HomeGenie.SecurityTriggered").Value = "0";
//Program.Parameter("Status.Level").Value = "0";

// Events History
var history = new List<dynamic>();
Expand Down Expand Up @@ -1041,6 +1041,7 @@ When.WebServiceCallReceived(Program.Module.Domain + "/" + Program.Module.Address
res = JsonConvert.SerializeObject(history);
break;
}
Program.UpdateModuleDatabase();

}
}
Expand All @@ -1056,6 +1057,15 @@ When.WebServiceCallReceived(Program.Module.Domain + "/" + Program.Module.Address
// main program loop
var sirenModules = Modules.WithFeature("HomeGenie.SecurityAlarm").OfDeviceType("Siren");
var alarmModules = Modules.WithFeature("HomeGenie.SecurityAlarm").OfDeviceType("Dimmer,Switch,Light");

if (Program.Parameter("Status.Level").Value != "0") {
var triggeredProgram = Program.Option("Trigger.TriggeredProgram").Value;
if (triggeredProgram != "")
{
Program.Run(triggeredProgram);
}
}

while (Program.IsEnabled)
{
if (Program.Parameter("HomeGenie.SecurityTriggered").Value == "1")
Expand Down Expand Up @@ -1113,38 +1123,16 @@ while (Program.IsEnabled)
Pause(1);
}
</ScriptSource>
<ScriptErrors>[]</ScriptErrors>
<ScriptErrors />
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>90</Address>
<Name>Security Alarm System</Name>
<Description>Basic Security Alarm System</Description>
<Group>Security</Group>
<Features>
<ProgramFeature>
<FieldType>checkbox</FieldType>
<ForDomains />
<ForTypes>Sensor,DoorWindow,DoorLock</ForTypes>
<Property>HomeGenie.SecuritySensor</Property>
<Description>Use as Security Sensor</Description>
</ProgramFeature>
<ProgramFeature>
<FieldType>checkbox</FieldType>
<ForDomains />
<ForTypes>Sensor,DoorWindow,DoorLock</ForTypes>
<Property>HomeGenie.SecurityTriggerHome</Property>
<Description>Also trigger when armed Home</Description>
</ProgramFeature>
<ProgramFeature>
<FieldType>checkbox</FieldType>
<ForDomains />
<ForTypes>Siren,Light,Dimmer,Switch</ForTypes>
<Property>HomeGenie.SecurityAlarm</Property>
<Description>Use as Security Alarm</Description>
</ProgramFeature>
</Features>
<Features />
<AutoRestartEnabled>false</AutoRestartEnabled>
<ActivationTime xsi:nil="true" />
<TriggerTime>2018-12-19T01:34:15.654851Z</TriggerTime>
<ActivationTime>2019-02-05T20:01:16.951542Z</ActivationTime>
<TriggerTime xsi:nil="true" />
<Type>CSharp</Type>
<IsEnabled>true</IsEnabled>
</ProgramBlock>
Expand Down Expand Up @@ -2014,29 +2002,29 @@ while (Program.IsEnabled)
<IsEnabled>true</IsEnabled>
</ProgramBlock>
<ProgramBlock>
<ScriptSetup>IPHostEntry host;
string localIP = "1";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
localIP = ip.ToString();
localIP = localIP.Substring(localIP.LastIndexOf(".") + 1);
}
}
Program
.AddOption("ClientId", "hg-" + localIP, "0. Enter unique ID for this client", "text")
.AddOption("ServerAddress", "", "1. MQTT server address", "text")
.AddOption("ServerPort", "1883", "2. MQTT server port", "text")
.AddOption("WebSockets", "On", "3. Connect using WebSockets", "checkbox")
.AddOption("ServerTopic", "#", "4. Topic", "text")
.AddOption("Username", "", "5. Username (optional)", "text")
.AddOption("Password", "", "6. Password (optional)", "text")
.AddFeature("", "", "MQTT.SensorPublish", "Publish this module events", "checkbox")
.Run();
</ScriptSetup>
<ScriptSource>string server = Program.Option("ServerAddress").Value.Trim();
<ScriptSetup>IPHostEntry host;
string localIP = "1";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
localIP = ip.ToString();
localIP = localIP.Substring(localIP.LastIndexOf(".") + 1);
}
}
Program
.AddOption("ClientId", "hg-" + localIP, "0. Enter unique ID for this client", "text")
.AddOption("ServerAddress", "", "1. MQTT server address", "text")
.AddOption("ServerPort", "1883", "2. MQTT server port", "text")
.AddOption("WebSockets", "", "3. Connect using WebSockets", "checkbox")
.AddOption("ServerTopic", "#", "4. Topic", "text")
.AddOption("Username", "", "5. Username (optional)", "text")
.AddOption("Password", "", "6. Password (optional)", "text")
.AddFeature("", "", "MQTT.SensorPublish", "Publish this module events", "checkbox")
.Run();
</ScriptSetup>
<ScriptSource>string server = Program.Option("ServerAddress").Value.Trim();
int port = 1883; int.TryParse(Program.Option("ServerPort").Value, out port);
string topic = Program.Option("ServerTopic").Value.Trim();
string clientid = Program.Option("ClientId").Value.Trim();
Expand Down Expand Up @@ -2196,27 +2184,27 @@ When.ModuleParameterChanged( (module, property) =&gt; {
});

Program.GoBackground();</ScriptSource>
<ScriptErrors>[]</ScriptErrors>
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>77</Address>
<Name>MQTT Network</Name>
<Description>Share modules with other HomeGenie servers connected to the same MQTT network.
<ScriptErrors>[]</ScriptErrors>
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>77</Address>
<Name>MQTT Network</Name>
<Description>Share modules with other HomeGenie servers connected to the same MQTT network.
Other servers will automatically inherit the published module once an event is generated from it.</Description>
<Group>Interconnections</Group>
<Features>
<ProgramFeature>
<FieldType>checkbox</FieldType>
<ForDomains />
<ForTypes />
<Property>MQTT.SensorPublish</Property>
<Description>Publish this module events</Description>
</ProgramFeature>
</Features>
<AutoRestartEnabled>false</AutoRestartEnabled>
<ActivationTime xsi:nil="true" />
<TriggerTime xsi:nil="true" />
<Type>CSharp</Type>
<IsEnabled>false</IsEnabled>
<Group>Interconnections</Group>
<Features>
<ProgramFeature>
<FieldType>checkbox</FieldType>
<ForDomains />
<ForTypes />
<Property>MQTT.SensorPublish</Property>
<Description>Publish this module events</Description>
</ProgramFeature>
</Features>
<AutoRestartEnabled>false</AutoRestartEnabled>
<ActivationTime>2019-02-05T19:09:57.43412Z</ActivationTime>
<TriggerTime>2019-02-05T19:09:57.577187Z</TriggerTime>
<Type>CSharp</Type>
<IsEnabled>false</IsEnabled>
</ProgramBlock>
<ProgramBlock>
<ScriptSetup>Program.Setup(()=&gt;{
Expand Down
Binary file modified BaseFiles/Common/programs/112.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/142.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/145.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/16.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/180.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/20.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/200.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/26.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/29.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/34.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/39.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/40.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/505.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/6.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/7.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/73.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/74.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/75.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/76.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/77.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/78.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/8.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/81.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/82.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/88.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/90.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/91.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/92.dll
Binary file not shown.
Binary file modified BaseFiles/Common/programs/93.dll
Binary file not shown.
9 changes: 8 additions & 1 deletion HomeGenie/Automation/Scripting/ProgramHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,14 @@ public Module Module
}
}

/// <summary>
/// Force update module database with current data.
/// </summary>
public bool UpdateModuleDatabase()
{
return homegenie.UpdateModulesDatabase();
}

public ProgramHelper Reset()
{
this.initialized = false;
Expand All @@ -834,7 +842,6 @@ public ProgramHelper Reset()
return this;
}


private void RelocateProgramModule()
{
// force automation modules regeneration
Expand Down

0 comments on commit 98fece6

Please sign in to comment.