Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello world example and confirming the script works with 151S AVR #8

Open
felagund opened this issue Apr 3, 2021 · 1 comment
Open

Comments

@felagund
Copy link

felagund commented Apr 3, 2021

Thank you for the library. It works with my 151S AVR model.

I have never used php before so it took me a bit to set it up, my streamlined notes on a Ubuntu/Debian are below. My use case was to be able to use a script to turn the AVR off when I turn my Raspberry Pi off automatically. This accomplishes it:

  1. Install the composer dependency manager (for Debian/Ubuntu):
    sudo apt install composer
  2. Create a working directory somewhere:
    mkdir my_avr_script ; cd my_avr_script
  3. Create a composer.json file in your working directory with this content:
{
    "require-dev": {
    "karimgeiger/hkapi": "1.0.x-dev"
}
}

  1. Install the library with:
    composer update ; composer install
  2. Create an example script turn_off.php with this content:
<?php require __DIR__ . '/vendor/autoload.php'; 
echo "Hello World!'\n";
$hk = new \HKAPI\API('192.168.2.206',10025, new \HKAPI\Devices\AVR());
sleep(3);
$hk->zone('Main Zone')->off();
?>
  1. Turn your AVR off with:
    php turn_off.php

It should output:

Hello World!
PHP Notice:  Undefined offset: 0 in /home/pi/skripty_na_AVR/vendor/karimgeiger/hkapi/lib/Zone.php on line 95

(the first confirms the script ran and the second is a PHP warning that can be safely ignored it seems)
and the AVR should turn off after three seconds.

@felagund
Copy link
Author

@KarimGeiger I noticed in other issues you do not get notifications so here I am trying to send you one.

Also, I have a question - any idea how one could turn the device off instead of putting it to sleep? Becasue putting it to sleep is what $hk->zone('Main Zone')->off(); does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant