fix: support Symcon numeric dimmers and independent blind slat controls
This commit is contained in:
1 parent
6050bb7c88
commit
d7d7435e96
7 files changed
+443
-337
No files matched your search
+30
-5
@@ -9,15 +9,25 @@ $variables = [
|
||||
2 => ['VariableType' => 2, 'VariableAction' => 99],
|
||||
3 => ['VariableType' => 2, 'VariableProfile' => '~Temperature'],
|
||||
4 => ['VariableType' => 2, 'VariableProfile' => '~Temperature'],
|
||||
5 => ['VariableType' => 0, 'VariableAction' => 0]
|
||||
5 => ['VariableType' => 0, 'VariableAction' => 0],
|
||||
6 => ['VariableType' => 1, 'VariableAction' => 99],
|
||||
7 => ['VariableType' => 2, 'VariableProfile' => '~Intensity.1', 'VariableAction' => 99],
|
||||
8 => ['VariableType' => 1, 'VariableAction' => 99],
|
||||
9 => ['VariableType' => 1, 'VariableAction' => 99]
|
||||
];
|
||||
$presentations = [1 => ['SUFFIX' => ' °C'], 2 => ['SUFFIX' => "\u{00A0}°C"], 3 => ['PROFILE' => '~Temperature'], 4 => ['SUFFIX' => ' W']];
|
||||
$presentations[6] = ['MIN' => 0, 'MAX' => 255, 'STEP_SIZE' => 1, 'USAGE_TYPE' => 2, 'SUFFIX' => '%'];
|
||||
$presentations[8] = ['MIN' => 0, 'MAX' => 100, 'STEP_SIZE' => 1];
|
||||
$presentations[9] = ['MIN' => 0, 'MAX' => 255, 'STEP_SIZE' => 1];
|
||||
function IPS_GetVariable(int $id): array { global $variables; return $variables[$id] + ['VariableProfile' => '', 'VariableCustomProfile' => '', 'VariableAction' => 0, 'VariableCustomAction' => 0]; }
|
||||
function IPS_GetVariablePresentation(int $id): array { global $presentations; return $presentations[$id] ?? []; }
|
||||
function IPS_VariableProfileExists(string $profile): bool { return $profile === '~Temperature'; }
|
||||
function IPS_GetVariableProfile(string $profile): array { return ['Suffix' => ' °C']; }
|
||||
function GetValue(int $id): float|bool { return $id === 5 ? true : 21.75; }
|
||||
function IPS_VariableProfileExists(string $profile): bool { return in_array($profile, ['~Temperature', '~Intensity.1'], true); }
|
||||
function IPS_GetVariableProfile(string $profile): array { return $profile === '~Intensity.1' ? ['MinValue' => 0, 'MaxValue' => 1, 'StepSize' => 0.01, 'Suffix' => ' %'] : ['Suffix' => ' °C']; }
|
||||
function GetValue(int $id): float|int|bool { return match ($id) { 5 => true, 6, 9 => 128, 7 => 0.4, 8 => 40, default => 21.75 }; }
|
||||
function GetValueFormatted(int $id): string { return $id === 5 ? 'An' : '21,75'; }
|
||||
$writes = [];
|
||||
function RequestAction(int $id, mixed $value): void { global $writes; $writes[] = [$id, $value]; }
|
||||
function SetValue(int $id, mixed $value): void { global $writes; $writes[] = [$id, $value]; }
|
||||
|
||||
require __DIR__ . '/../NextFloor/module.php';
|
||||
$module = new NextFloor();
|
||||
@@ -36,4 +46,19 @@ $override = $describe->invoke($module, 4, 'Temperatur', 'Haus / Temperatur', 10)
|
||||
check($override['attributes']['unit_of_measurement'] === 'W' && $override['attributes']['device_class'] === 'power', 'The effective presentation overrides a stale legacy profile and ancestor names');
|
||||
$boolean = $describe->invoke($module, 5, 'Kontakt', 'Haus / Kontakt', 10);
|
||||
check(!isset($boolean['attributes']['symcon_numeric_value']), 'Boolean values are not advertised as numeric readings');
|
||||
echo "OK: Symcon 9 presentation units, KNX float readings, stable mappings and legacy profiles\n";
|
||||
$dimmer = $describe->invoke($module, 6, 'Dimmer', 'Haus / Dimmer', 10);
|
||||
check($dimmer['attributes']['brightness'] === 128, 'An integer dimmer uses its real 0-255 range');
|
||||
$floatDimmer = $describe->invoke($module, 7, 'Wert', 'Haus / Wert', 10);
|
||||
check($floatDimmer['attributes']['brightness'] === 102, 'A normalized float dimmer uses its legacy 0-1 profile range');
|
||||
$write = new ReflectionMethod($module, 'writeAction');
|
||||
$write->invoke($module, 6, 'light', 'turn_on', ['brightness_pct' => 50]);
|
||||
$write->invoke($module, 7, 'light', 'turn_on', ['brightness_pct' => 30]);
|
||||
$write->invoke($module, 8, 'cover', 'set_cover_position', ['position' => 60]);
|
||||
$write->invoke($module, 9, 'cover', 'set_cover_tilt_position', ['tilt_position' => 25]);
|
||||
$write->invoke($module, 6, 'light', 'turn_on', ['brightness' => 200]);
|
||||
check($writes === [[6, 128], [7, 0.3], [8, 60], [9, 64], [6, 200]], 'Light, position and slat commands target the right variables, scale and cast to the native type');
|
||||
$count = count($writes);
|
||||
try { $write->invoke($module, 8, 'cover', 'stop_cover', []); throw new RuntimeException('Unsupported stop was accepted'); } catch (InvalidArgumentException) {}
|
||||
try { $write->invoke($module, 8, 'cover', 'set_cover_position', ['position' => 'invalid']); throw new RuntimeException('Invalid percentage was accepted'); } catch (InvalidArgumentException) {}
|
||||
check(count($writes) === $count, 'Invalid values and unsupported stop never move an actuator');
|
||||
echo "OK: Symcon 9 units, KNX float readings, integer/float dimmers, separate blind actions, range scaling and legacy profiles\n";
|
||||
Reference in new issue
Block a user