Skip to content

Commit

Permalink
v1.4.0-beta.46
Browse files Browse the repository at this point in the history
- Added new custom widget example (analog clock)
- Added *dotnet/iot* DHT-11 and DHT-22 programs
- Fixed encrypted fields bug when saving virtual modules
  • Loading branch information
genemars committed Sep 10, 2023
1 parent 6821994 commit ae242cb
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 38 deletions.
2 changes: 1 addition & 1 deletion assets/build/all/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@

</div>

<script src="runtime.b92e2ca178ebbf4a.js" type="module"></script><script src="polyfills.a360d6e45b80c065.js" type="module"></script><script src="scripts.0dcb4f0a61221c18.js" defer></script><script src="main.bd68f79f3efc8d63.js" type="module"></script>
<script src="runtime.b92e2ca178ebbf4a.js" type="module"></script><script src="polyfills.a360d6e45b80c065.js" type="module"></script><script src="scripts.0dcb4f0a61221c18.js" defer></script><script src="main.a3047256dd4985fd.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions assets/build/all/app/ngsw.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"configVersion": 1,
"timestamp": 1693905412921,
"timestamp": 1694205053132,
"index": "/app/index.html",
"assetGroups": [
{
Expand All @@ -15,7 +15,7 @@
"/app/613.16b9c52c0ae74833.js",
"/app/859.0f150be9c99a6b5a.js",
"/app/index.html",
"/app/main.bd68f79f3efc8d63.js",
"/app/main.a3047256dd4985fd.js",
"/app/manifest.webmanifest",
"/app/polyfills.a360d6e45b80c065.js",
"/app/runtime.b92e2ca178ebbf4a.js",
Expand Down Expand Up @@ -729,8 +729,8 @@
"/app/assets/widgets/weather/images_alt/thunder.svg": "2ace7038dfd663330cecc350d680ef08206d62ff",
"/app/assets/widgets/weather/images_alt/weather.svg": "c719c09048977fd40688272316b35ddf1bdf89e8",
"/app/assets/workers/typings-worker.js": "8df10d867c12d36cdebfb7e16caacd0020db301f",
"/app/index.html": "d1f51f4c4687d9ed788041edb81e542671a24e21",
"/app/main.bd68f79f3efc8d63.js": "024ef88a93fe57853d0044a481e3b0aa476656a9",
"/app/index.html": "e1bd4c4d3238b2c067b0f40f1d5af2ca3185e28a",
"/app/main.a3047256dd4985fd.js": "1ee1f8d502db5b2ced956f5e31d811a875b5e1ac",
"/app/manifest.webmanifest": "d47bb07a495e27ddf072f8702df373f79b4eb183",
"/app/polyfills.a360d6e45b80c065.js": "f317e1a3e4bb6a84068c7e1845a2ce8b2f956ee7",
"/app/runtime.b92e2ca178ebbf4a.js": "b50d841a4c50d466c34aab3267d3fb4afe87dede",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfModule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</ArrayOfModule>
<Module>
<Name>DHT-11 Sensor IoT</Name>
<Description>Read temperature and humidity from a DHT-11 connected to GPIO.
</Description>
<DeviceType>Program</DeviceType>
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>701</Address>
<Properties>
<ModuleParameter>
<Name>ConfigureOptions.GPIO.Pin</Name>
<Value />
<Description>Pin number</Description>
<FieldType>select:GPIO17 (pin 11)=17,GPIO27 (pin 13)=27,GPIO22 (pin 15)=22,GPIO4 (pin 7)=4,GPIO5 (pin 29)=5,GPIO6 (pin 31)=6,GPIO13 (pin 33)=13,GPIO19 (pin 35)=19,GPIO26 (pin 37)=26,GPIO23 (pin 16)=23,GPIO24 (pin 18)=24,GPIO25 (pin 22)=25,GPIO12 (pin 32)=12,GPIO16 (pin 36)=16,GPIO21 (pin 40)=21</FieldType>
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:21:58.9506147Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>ConfigureOptions.UpdateInterval</Name>
<Value>60</Value>
<Description>Update Interval (seconds)</Description>
<FieldType>slider:10:3600:10</FieldType>
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:18:16.8321314Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>Program.Notification</Name>
<Value>{"Title":"DHT-11 Sensor IoT","Message":"Data pin not selected. [program_configure,program_disable]"}</Value>
<Description />
<FieldType />
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:22:39.0487788Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>Program.Status</Name>
<Value>Running</Value>
<Description />
<FieldType />
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:22:39.0384164Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>Runtime.Error</Name>
<Value />
<Description />
<FieldType />
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:21:58.5073868Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>VirtualModule.ParentId</Name>
<Value>701</Value>
<Description />
<FieldType />
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:22:18.661793Z</UpdateTime>
</ModuleParameter>
<ModuleParameter>
<Name>Widget.DisplayModule</Name>
<Value />
<Description />
<FieldType />
<ParentId>0</ParentId>
<UpdateTime>2023-09-10T19:19:13.8595219Z</UpdateTime>
</ModuleParameter>
</Properties>
<Stores />
</Module>
</ArrayOfModule>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"repository":"homegenie","id":"homegenie-iot-net","version":"1.0.0","description":"GPIO, SPI, I2C examples based on .NET IoT libraries.\n\nhttps://learn.microsoft.com/en-us/dotnet/iot/intro","programs":[{"repository":"homegenie","packageId":"homegenie-iot-net","packageVersion":"1.0.0","hid":"700","id":"gpio-pin","required":false,"version":"1.0.1","checksum":"7EFCCA46A94A656A65E9393588A20880","installed":false}],"modules":null,"groups":[],"schedules":[]}
{"repository":"homegenie","id":"homegenie-iot-net","version":"1.0.0","description":"GPIO, SPI, I2C examples based on .NET IoT libraries.\n\nhttps://learn.microsoft.com/en-us/dotnet/iot/intro","programs":[{"repository":"homegenie","packageId":"homegenie-iot-net","packageVersion":"1.0.0","hid":"701","id":"dht-11-sensor","required":false,"version":"1.0.0","checksum":"17935A6F55B291167A8255830C967134","installed":false},{"repository":"homegenie","packageId":"homegenie-iot-net","packageVersion":"1.0.0","hid":"702","id":"dht-22-sensor","required":false,"version":"1.0.0","checksum":"9B9C74DB0A228896C6BB2877D21B2200","installed":false},{"repository":"homegenie","packageId":"homegenie-iot-net","packageVersion":"1.0.0","hid":"700","id":"gpio-pin","required":false,"version":"1.0.1","checksum":"7EFCCA46A94A656A65E9393588A20880","installed":false}],"modules":null,"groups":[],"schedules":[]}
Original file line number Diff line number Diff line change
@@ -1,5 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfProgramBlock xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ArrayOfProgramBlock xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ProgramBlock>
<ScriptSetup>var gpio_pins = new string[]{
"GPIO17 (pin 11)=17",
"GPIO27 (pin 13)=27",
"GPIO22 (pin 15)=22",

"GPIO4 (pin 7)=4",
"GPIO5 (pin 29)=5",
"GPIO6 (pin 31)=6",
"GPIO13 (pin 33)=13",
"GPIO19 (pin 35)=19",
"GPIO26 (pin 37)=26",

"GPIO23 (pin 16)=23",
"GPIO24 (pin 18)=24",
"GPIO25 (pin 22)=25",

"GPIO12 (pin 32)=12",
"GPIO16 (pin 36)=16",
// "GPIO20 (pin 38)=20", // &lt;-- this pin seems to be used by the system
"GPIO21 (pin 40)=21"
};

Program.Setup(() =&gt; {
Program
.AddOption("GPIO.Pin", "", "Pin number", "select:" + string.Join(",", gpio_pins))
.AddOption("UpdateInterval", "60", "Update Interval (seconds)", "slider:10:3600:10");
});
Program.Run();
</ScriptSetup>
<ScriptSource>// Based .NET IoT Libraries
// Documentation:
// https://learn.microsoft.com/en-us/dotnet/iot/intro
// Device Bindings:
// https://github.com/dotnet/iot/blob/main/src/devices/README.md

#using Iot.Device.DHTxx

// restart and reconfigure if a configuration parameter changed
When.ModuleParameterChanged((module, property) =&gt; {
if (module.Instance == Program.Module &amp;&amp; property.Name.StartsWith("ConfigureOptions.")) {
Program.Restart();
}
// returning true, will route event to other listeners
return true;
});

var notificationButtons = " [program_configure,program_disable]";
var pin = (int)Program.Option("GPIO.Pin").DecimalValue;
if (pin &lt;= 0) {
Program.Notify("Data pin not selected." + notificationButtons);
Pause(10);
return;
}

var moduleDomain = "Components.DHT11";
var moduleAddress = pin.ToString(); // get GPIO#
Program.AddModule(moduleDomain, moduleAddress, "Sensor");
var dhtModule = Modules
.InDomain(moduleDomain)
.WithAddress(moduleAddress).Get();

while (Program.IsEnabled)
{


try {


using (Dht11 dht = new Dht11(pin))
{
Temperature temperature = default;
RelativeHumidity humidity = default;
bool success = dht.TryReadHumidity(out humidity)
&amp;&amp; dht.TryReadTemperature(out temperature);
if (success)
{
// data read succesfully
dhtModule
.Emit("Sensor.Humidity", humidity.Percent)
.Emit("Sensor.Temperature", temperature.DegreesCelsius);
}
else
{
Program.Notify("Could not read data from sensor." + notificationButtons);
}
}

} catch (Exception e) {
Program.Notify("Error." + e.Message);
}


var pause = Program.Option("UpdateInterval").DecimalValue;
if (pause == 0) pause = 60; // default pause is 1 minute
Pause(pause);
}
</ScriptSource>
<ScriptContext />
<ScriptErrors>[]</ScriptErrors>
<Data />
<PackageInfo>
<Repository>homegenie</Repository>
<PackageId>homegenie-iot-net</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<Id>dht-11-sensor</Id>
<Version>1.0.0</Version>
<Required>false</Required>
<Checksum>17935A6F55B291167A8255830C967134</Checksum>
</PackageInfo>
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>701</Address>
<Name>DHT-11 Sensor IoT</Name>
<Description>Read temperature and humidity from a DHT-11 connected to GPIO.
</Description>
<Group>Raspberry Pi</Group>
<Features />
<AutoRestartEnabled>false</AutoRestartEnabled>
<Cloneable>true</Cloneable>
<Type>CSharp</Type>
<IsEnabled>true</IsEnabled>
</ProgramBlock>
<ProgramBlock>
<ScriptSetup>var gpio_pins = new string[]{
"GPIO17 (pin 11)=17",
"GPIO27 (pin 13)=27",
"GPIO22 (pin 15)=22",

"GPIO4 (pin 7)=4",
"GPIO5 (pin 29)=5",
"GPIO6 (pin 31)=6",
"GPIO13 (pin 33)=13",
"GPIO19 (pin 35)=19",
"GPIO26 (pin 37)=26",

"GPIO23 (pin 16)=23",
"GPIO24 (pin 18)=24",
"GPIO25 (pin 22)=25",

"GPIO12 (pin 32)=12",
"GPIO16 (pin 36)=16",
// "GPIO20 (pin 38)=20", // &lt;-- this pin seems to be used by the system
"GPIO21 (pin 40)=21"
};

Program.Setup(() =&gt; {
Program
.AddOption("GPIO.Pin", "", "Pin number", "select:" + string.Join(",", gpio_pins))
.AddOption("UpdateInterval", "60", "Update Interval (seconds)", "slider:10:3600:10");
});
Program.Run();
</ScriptSetup>
<ScriptSource>// Based .NET IoT Libraries
// Documentation:
// https://learn.microsoft.com/en-us/dotnet/iot/intro
// Device Bindings:
// https://github.com/dotnet/iot/blob/main/src/devices/README.md

#using Iot.Device.DHTxx

// restart and reconfigure if a configuration parameter changed
When.ModuleParameterChanged((module, property) =&gt; {
if (module.Instance == Program.Module &amp;&amp; property.Name.StartsWith("ConfigureOptions.")) {
Program.Restart();
}
// returning true, will route event to other listeners
return true;
});

var notificationButtons = " [program_configure,program_disable]";
var pin = (int)Program.Option("GPIO.Pin").DecimalValue;
if (pin &lt;= 0) {
Program.Notify("Data pin not selected." + notificationButtons);
Pause(10);
return;
}

var moduleDomain = "Components.DHT22";
var moduleAddress = pin.ToString(); // get GPIO#
Program.AddModule(moduleDomain, moduleAddress, "Sensor");
var dhtModule = Modules
.InDomain(moduleDomain)
.WithAddress(moduleAddress).Get();

while (Program.IsEnabled)
{


try {


using (Dht22 dht = new Dht22(pin))
{
Temperature temperature = default;
RelativeHumidity humidity = default;
bool success = dht.TryReadHumidity(out humidity)
&amp;&amp; dht.TryReadTemperature(out temperature);
if (success)
{
// data read succesfully
dhtModule
.Emit("Sensor.Humidity", humidity.Percent)
.Emit("Sensor.Temperature", temperature.DegreesCelsius);
}
else
{
Program.Notify("Could not read data from sensor." + notificationButtons);
}
}

} catch (Exception e) {
Program.Notify("Error." + e.Message);
}


var pause = Program.Option("UpdateInterval").DecimalValue;
if (pause == 0) pause = 60; // default pause is 1 minute
Pause(pause);
}
</ScriptSource>
<ScriptContext />
<ScriptErrors>[]</ScriptErrors>
<Data />
<PackageInfo>
<Repository>homegenie</Repository>
<PackageId>homegenie-iot-net</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<Id>dht-22-sensor</Id>
<Version>1.0.0</Version>
<Required>false</Required>
<Checksum>9B9C74DB0A228896C6BB2877D21B2200</Checksum>
</PackageInfo>
<Domain>HomeAutomation.HomeGenie.Automation</Domain>
<Address>702</Address>
<Name>DHT-22 Sensor IoT</Name>
<Description>Read temperature and humidity from a DHT-22 connected to GPIO.
</Description>
<Group>Raspberry Pi</Group>
<Features />
<AutoRestartEnabled>false</AutoRestartEnabled>
<Cloneable>true</Cloneable>
<Type>CSharp</Type>
<IsEnabled>false</IsEnabled>
</ProgramBlock>
<ProgramBlock>
<ScriptSetup>// Based .NET IoT Libraries
// Documentation:
Expand Down Expand Up @@ -135,7 +379,7 @@ else
Program.GoBackground();
</ScriptSource>
<ScriptContext />
<ScriptErrors>[{"Line":33,"Column":6,"EndLine":33,"EndColumn":7,"ErrorMessage":"Unexpected symbol `GpioController', expecting `('","ErrorNumber":"CS1525","CodeBlock":"CR"},{"Line":33,"Column":38,"EndLine":33,"EndColumn":39,"ErrorMessage":"Unexpected symbol `)', expecting `(' or `type'","ErrorNumber":"CS1525","CodeBlock":"CR"},{"Line":37,"Column":62,"EndLine":37,"EndColumn":63,"ErrorMessage":"Unexpected symbol `?'","ErrorNumber":"CS1525","CodeBlock":"CR"}]</ScriptErrors>
<ScriptErrors />
<Data />
<PackageInfo>
<Repository>homegenie</Repository>
Expand Down
Loading

0 comments on commit ae242cb

Please sign in to comment.