This is a SUPLA Cloud extension that enables basic events support. Installation includes changing some sources of SUPLA Cloud instance (yes, you need to have your own SUPLA Cloud, it cannot use it on a shared official platform at supla.org).
Event specification consist of a condition
(what should happen in order for the event to be perceived as occured) and a webhooks
, that is, URLs to call in such cases. The condition
is a Twig expression with a simple state
function provided. state(XX)
returns a state of a channel with ID XX
. The returned value depends on the channel function. You will find the example states for specific functions helpful. Take a look at example config.yml
for different possibilities.
Event specification might also contain a time_conditions
, that is cron expression (or array of them) specifying when the event should be active. If the time condition is not met, the condition is not checked at all so the webhook will not be fired.
If you use SUPLA Scripts and have public URLs for the scenes, you might link the event with a scene.
- Install SUPLA with Docker (yes, you need to have your own SUPLA Cloud).
- Downlad the SUPLA Cloud extension from this gist (for example into the home directory, doesn't matter):
wget https://gist.githubusercontent.com/fracz/9aa9923aec02db8b5ef5baf09113fa63/raw/d7c8dd94a169ce804433c871cd59128ab838800b/SimulateEventsCommand.php wget https://gist.githubusercontent.com/fracz/9aa9923aec02db8b5ef5baf09113fa63/raw/d7c8dd94a169ce804433c871cd59128ab838800b/events.yml
- Copy the command into the SUPLA Cloud container and clear the cache, so the framework notices it:
docker cp SimulateEventsCommand.php supla-cloud:/var/www/cloud/src/SuplaBundle/Command/SimulateEventsCommand.php docker exec supla-cloud rm -fr var/cache/prod
- Adjust the
events.yml
configuration to match your needs and copy it into the SUPLA Cloud container:docker cp events.yml supla-cloud:/var/www/cloud/src/SuplaBundle/Command/events.yml
- Add the following entry to your host crontab (you edit crontabs with
crontab -e
):* * * * * /usr/bin/docker exec -u www-data supla-cloud php bin/console supla:unofficial:simulate-events
Just adjust the events.yml
config and copy it again into the container (point 4 in the Installation section).
If there is some fix published, just download the command again and copy it inside the container.
wget -N https://gist.githubusercontent.com/fracz/9aa9923aec02db8b5ef5baf09113fa63/raw/d7c8dd94a169ce804433c871cd59128ab838800b/SimulateEventsCommand.php
docker cp SimulateEventsCommand.php supla-cloud:/var/www/cloud/src/SuplaBundle/Command/SimulateEventsCommand.php
If you suppose it's not working, try to disable the crontab and run the command directly:
docker exec -u www-data supla-cloud php bin/console supla:unofficial:simulate-events --dispatch
If you have made some configuration errors, this command should provide you with a helpful output.
docker cp events.yml supla-cloud:/var/www/cloud/src/SuplaBundle/Command/events.yml
There is a forum thread about this solution here. Gist or youtube comments are also welcome.