/status/`; * simple control is `/command/`. Vendor specifics stay here (H3). */ class ShellyTopics { /** Topics the listener subscribes to. `+` matches any device prefix. */ public static function subscriptions(): array { return [ '+/status/#', ]; } /** * Parse a status topic into [prefix, component], or null if it isn't one. * e.g. "shellyplus1-a1b2c3/status/switch:0" => ['shellyplus1-a1b2c3', 'switch:0'] */ public static function parseStatus(string $topic): ?array { if (! preg_match('#^(?[^/]+)/status/(?.+)$#', $topic, $m)) { return null; } return [$m['prefix'], $m['component']]; } /** JSON-RPC topic for control (Switch.Set, Light.Set, Shelly.Reboot, …). */ public static function rpcTopic(string $prefix): string { return "{$prefix}/rpc"; } }