0, 'state' => true]); $this->assertSame('input:0', $on[0]['key']); $this->assertSame('input', $on[0]['type']); $this->assertSame(['on' => true], $on[0]['state']); $off = ShellyNormalizer::normalize('input:1', ['id' => 1, 'state' => false]); $this->assertSame(['on' => false], $off[0]['state']); } public function test_analog_or_count_input_is_not_a_contact(): void { $this->assertSame([], ShellyNormalizer::normalize('input:0', ['id' => 0, 'percent' => 40])); $this->assertSame([], ShellyNormalizer::normalize('input:0', ['id' => 0, 'state' => null])); } public function test_contact_component_supports_three_state_tilt(): void { $tilted = ShellyNormalizer::normalize('contact:0', ['position' => 'tilted']); $this->assertSame('contact', $tilted[0]['type']); $this->assertSame(['open' => true, 'position' => 'tilted'], $tilted[0]['state']); $window = ShellyNormalizer::normalize('window:0', ['open' => true]); $this->assertSame(['open' => true, 'position' => 'open'], $window[0]['state']); $closed = ShellyNormalizer::normalize('contact:0', ['state' => false]); $this->assertSame(['open' => false, 'position' => 'closed'], $closed[0]['state']); } public function test_switch_with_power_still_normalizes(): void { $updates = ShellyNormalizer::normalize('switch:0', ['output' => true, 'apower' => 12.7]); $this->assertSame('switch', $updates[0]['type']); $this->assertTrue($updates[0]['state']['on']); $this->assertSame('power', $updates[1]['type']); $this->assertSame(13, $updates[1]['state']['watts']); } public function test_contact_is_a_primary_onboarding_type(): void { $this->assertContains('contact', ShellyNormalizer::PRIMARY_TYPES); } }