Skip to content

Commit

Permalink
Update v3.0.20221231
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilkware committed Dec 14, 2023
1 parent 09efbec commit d931ec7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Magic Home Controller/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"7 colors run in olivary + 7 colors change quickly + 7 colors flash": "7 Farben laufen olivenförmig + 7 Farben schnell wechselnd + 7 Farben blinken",
"7 colors run gradually + 7 colors run in olivary + 7 colors change quickly + 7 color flash": "7 Farben laufen stufenweise + 7 Farben laufen olivenförmig + 7 Farben schnell wechselnd + 7 Farben blinken",
"Source code, donation and licence ...": "Quellcode, Spende und Lizenz ...",
"The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommzerielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen."
"The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommerzielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen."
}
}
}
2 changes: 1 addition & 1 deletion Magic Home Controller/module.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"id": "{E3529714-0243-4D6A-A8F1-899EEF818A1F}",
"name": "Magic Home Controller",
"url": "https://wilkware.de/ip-symcon-module/mhc/",
"type": 3,
"vendor": "Magic Home",
"aliases": [
"Magic Home Controller",
"LED Wifi Controller",
"LED Strips Controller"
],
"url": "https://wilkware.de/ip-symcon-module/mhc/",
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
Expand Down
3 changes: 2 additions & 1 deletion Magic Home Discovery/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
{
"type": "SelectCategory",
"name": "TargetCategory",
"caption": "Target Category:"
"caption": "Target Category:",
"visible": false
}
],
"actions": [
Expand Down
2 changes: 1 addition & 1 deletion Magic Home Discovery/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Model name": "Modellename",
"Device state": "Gerätestatus",
"Source code, donation and licence ...": "Quellcode, Spende und Lizenz ...",
"The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommzerielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen."
"The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommerzielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen."
}
}
}
2 changes: 1 addition & 1 deletion Magic Home Discovery/module.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "{5331D9F3-1DE9-C329-FE88-8F5EED65FF85}",
"name": "Magic Home Discovery",
"url": "https://wilkware.de/ip-symcon-module/mhc/",
"type": 5,
"vendor": "Magic Home",
"aliases": [],
"url": "https://wilkware.de/ip-symcon-module/mhc/",
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
Expand Down
79 changes: 57 additions & 22 deletions Magic Home Discovery/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,69 @@ public function ApplyChanges()
public function GetConfigurationForm()
{
$form = json_decode(file_get_contents(__DIR__ . '/form.json'), true);
$controllers = $this->DiscoverController();
// Version check
$version = (float) IPS_GetKernelVersion();
// Save location
$location = $this->GetPathOfCategory($this->ReadPropertyInteger('TargetCategory'));
// Enable or disable "TargetCategory" for 6.x
if ($version < 7) {
$form['elements'][2]['visible'] = true;
}
// All installed devices
$installed = [];
foreach (IPS_GetInstanceListByModuleID(self::MODUL_CONTROLLER_ID) as $instance) {
$installed[IPS_GetProperty($instance, 'MAC')] = $instance;
}
// Discover controlers
$controllers = $this->DiscoverController();
// Collect all values
$values = [];
// Build configuration list values
if (!empty($controllers)) {
foreach ($controllers as $controller) {
$this->SendDebug(__FUNCTION__, $controller);
// only if we found the type of controller
if (isset($controller['number'])) {
$values[] = [
'instanceID' => $this->GetControlerInstances($controller['tcpip']),
'tcpip' => $controller['tcpip'],
'macid' => $controller['mac'],
'model' => $controller['model'],
'type' => MAGIC_HOME_CONTROLLER[$controller['number']][0],
'info' => $controller['info'],
'version' => $controller['version'],
'firmware' => $controller['firmware'],
'create' => [
[
'moduleID' => self::MODUL_CONTROLLER_ID,
'configuration' => ['TCPIP' => $controller['tcpip'], 'MAC' => $controller['mac'], 'MODEL' => $controller['model'], 'TYPE' => $controller['number']],
'location' => $location,
],
foreach ($controllers as $controller) {
$this->SendDebug(__FUNCTION__, $controller);
// only if we found the type of controller
if (isset($controller['number'])) {
$value = [
'tcpip' => $controller['tcpip'],
'macid' => $controller['mac'],
'model' => $controller['model'],
'type' => MAGIC_HOME_CONTROLLER[$controller['number']][0],
'info' => $controller['info'],
'version' => $controller['version'],
'firmware' => $controller['firmware'],
'create' => [
[
'moduleID' => self::MODUL_CONTROLLER_ID,
'configuration' => ['TCPIP' => $controller['tcpip'], 'MAC' => $controller['mac'], 'MODEL' => $controller['model'], 'TYPE' => $controller['number']],
'location' => ($version < 7) ? $location : [],
],
];
],
];
if (isset($installed[$controller['mac']])) {
$value['instanceID'] = $installed[$controller['mac']];
// remove it from the list
unset($installed[$controller['mac']]);
} else {
$value['instanceID'] = 0;
}
$values[] = $value;
}
}
foreach ($installed as $mac => $instance) {
// However, if an controller is not a discovered device
$values[] = [
'macid' => $mac,
'tcpip' => IPS_GetProperty($instance, 'TCPIP'),
'model' => IPS_GetProperty($instance, 'MODEL'),
'type' => MAGIC_HOME_CONTROLLER[IPS_GetProperty($instance, 'TYPE')][0],
'info' => '',
'version' => ' - ',
'firmware' => ' - ',
'instanceID' => $instance,
];
}
// Set available values
if (!empty($values)) {
$form['actions'][0]['values'] = $values;
}
return json_encode($form);
Expand Down

0 comments on commit d931ec7

Please sign in to comment.