Hallo,
ich verwende in einigen Konfigurator-Module (z.B. NetatmoWeather) dynamische Konfigurationsformulare. Dabei wird eine Auswahlliste mit Daten, die ich vorher geholt habe, gefüllt, aus dieser Liste soll ein Eintrag ausgewählt werden, der dann bei eine Aufruf einer entsprechende Aktion verarbeitet werden soll.
public function GetConfigurationForm()
{
$SendData = ['DataID' => '{DC5A0AD3-88A5-CAED-3CA9-44C20CC20610}'];
$data = $this->SendDataToParent(json_encode($SendData));
$this->SendDebug(__FUNCTION__, "data=$data", 0);
$options = [];
if ($data != '') {
$netatmo = json_decode($data, true);
$devices = $netatmo['body']['devices'];
foreach ($devices as $device) {
$station_name = $device['station_name'];
$options[] = ['label' => $station_name, 'value' => $station_name];
}
}
$formActions = [];
$formActions[] = ['type' => 'Select', 'name' => 'station_name', 'caption' => 'Station-Name', 'options' => $options];
$formActions[] = ['type' => 'Button', 'label' => 'Import of station', 'onClick' => 'NetatmoWeatherConfig_Doit($id, $station_name);'];
$formStatus = [];
$formStatus[] = ['code' => '101', 'icon' => 'inactive', 'caption' => 'Instance getting created'];
$formStatus[] = ['code' => '102', 'icon' => 'active', 'caption' => 'Instance is active'];
$formStatus[] = ['code' => '104', 'icon' => 'inactive', 'caption' => 'Instance is inactive'];
$formStatus[] = ['code' => '201', 'icon' => 'error', 'caption' => 'Instance is inactive (no data)'];
$formStatus[] = ['code' => '202', 'icon' => 'error', 'caption' => 'Instance is inactive (station missing)'];
$formStatus[] = ['code' => '203', 'icon' => 'error', 'caption' => 'Instance is inactive (no station)'];
return json_encode(['actions' => $formActions, 'status' => $formStatus]);
}
public function Doit(string $station_name)
{
....
Wenn kein Eintrags ausgewählt wurde, griff in IPS 4.4 eine Prüffunktion in Doit(), die erkannte, das kein Eintrag gewählt wurde und entsprechend reagierte.
In IPS 5 gibt es nun eine Fehlermeldung:
Error: Error: Uncaught TypeError: Argument 1 passed to NetatmoWeatherConfig:oit() must be of the type string, null given, called in /var/lib/symcon/scripts/__generated.inc.php on line 991 and defined in /var/lib/symcon/modules/NetatmoWeather/NetatmoWeatherConfig/module.php:93
Stack trace:
#0 /var/lib/symcon/scripts/__generated.inc.php(991): NetatmoWeatherConfig->Doit(NULL)
#1 /-(4): NetatmoWeatherConfig_Doit(4711, NULL)
#2 {main}
thrown
Error in Script /var/lib/symcon/modules/NetatmoWeather/NetatmoWeatherConfig/module.php on Line 93
134 in IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php (call IPSLogger_Out)
33 in IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php (call IPSLogger_Err)
121 in IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php (call IPSLogger_PhpErrorHandler)
in IPSLogger_PhpFatalErrorHandler
Das ist vermutlich der neuen PHP-Version und dem strikteren Typ-Checking geschuldet.
Hat jemand eine Idee, wie ich verhindern kann, das die Übergaben von NULL an Doit() ein Problem wird?
danke
demel