client->get(sprintf('%s/api/states/%s', $_ENV['HOMEASSISTANT_URL'], $entityId), [ 'headers' => [ 'Authorization' => 'Bearer ' . $_ENV['HOMEASSISTANT_TOKEN'], ], ]); return json_decode($response->getBody()->getContents(), true); } public function updateEntity(string $entityId, string $state, array $attributes = []): void { $this->client->post( sprintf('%s/api/states/%s', $_ENV['HOMEASSISTANT_URL'], $entityId), [ 'headers' => ['Authorization' => 'Bearer ' . $_ENV['HOMEASSISTANT_TOKEN']], 'json' => ['state' => $state, 'attributes' => $attributes], ] ); } function sendNotification(string $receiver, string $title, string $body): void { $this->client->post(sprintf('%s/api/services/notify/%s', $_ENV['HOMEASSISTANT_URL'], $receiver), [ 'headers' => [ 'Authorization' => 'Bearer ' . $_ENV['HOMEASSISTANT_TOKEN'], ], 'json' => ['message' => $body, 'title' => $title] ]); } }