Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ The following elements are currently not supported and not accessible through ro
- Full Screen Mode button: Looks like modern browser only allow to change to full screen mode upon user gesture. It seems not possible to change to full-screen using Javascript.
- Photoswipe download button: Not needed for Rotary Control. (well, if you can come up with a decent use-case, let us know).

**************
Other Remote Trigger (experimental)
**************
#### Remote trigger using Socket.io (experimental)
The trigger server controls and coordinates sending commands via socket.io to the photobooth client. Next to a hardware button, any socket.io client can connect to the trigger server over the network, and send a trigger command. This gives full flexibility to integrate other backend systems for trigger signals.

- Channel: `photobooth-socket`
Expand All @@ -270,6 +268,29 @@ The trigger server controls and coordinates sending commands via socket.io to th

This functionality is experimental and largely untested. Not sure if there is a use-case but if you have one, happy to learn about it. Currently this does not support rotary encoder use but could be if needed.

#### Remote trigger using simple web requests
*Note: This feature depends on the experimental Socket.io implementation and needs option `Hardware Button` - `Enable Hardware Buttons` to be active.*

Simple `GET` requests can be used to trigger single pictures or collages. Those endpoints can be found under `http://[Photobooth IP]:[Hardware Button Server Port]` where:
- `[Photobooth IP]` needs to match the configured value under `General` - `IP address of the Photobooth web server` and
- `[Hardware Button Server Port]` the value from `Hardware Button` - `Enable Hardware Buttons`

The available endpoints are:
- `[Base Url]/` - Simple help page with all available endpoints
- `[Base Url]/commands/start-picture` - Triggers a single picture
- `[Base Url]/commands/start-collage` - Triggers a collage

These trigger URLs can be used for example with [myStrom WiFi Buttons](https://mystrom.com/wifi-button/) or [Shelly Buttons](https://shelly.cloud/products/shelly-button-1-smart-home-automation-device/) (untested).

**Installation steps for myStrom WiFi Button**
- Be sure to connect the button to the same network as the photobooth
- The button can be configured using the following commands
```sh
curl --location -g --request POST http://[Button IP]/api/v1/action/single --data-raw get://[Photobooth IP]:[Hardware Button Server Port]/commands/start-picture

curl --location -g --request POST http://[Button IP]/api/v1/action/long --data-raw get://[Photobooth IP]:[Hardware Button Server Port]/commands/start-collage
```

<hr>

### How do I enable Kiosk Mode to automatically start Photobooth in full screen?
Expand Down
61 changes: 57 additions & 4 deletions src/js/remotebuzzer_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ fs.writeFile(pidFilename, PID, function (err) {
log('PID file created [', pidFilename, ']');
});

/* START WEBSOCKET SERVER */
log('Server starting on http://' + config.webserver.ip + ':' + config.remotebuzzer.port);
/* START HTTP & WEBSOCKET SERVER */
const baseUrl = 'http://' + config.webserver.ip + ':' + config.remotebuzzer.port;
log('Server starting on ' + baseUrl);

function photoboothAction(type) {
switch (type) {
Expand Down Expand Up @@ -102,7 +103,57 @@ function photoboothAction(type) {
}
}

const ioServer = require('socket.io')(config.remotebuzzer.port, {
/* CONFIGURE HTTP ENDPOINTS */
const requestListener = function (req, res) {
function sendText(content, contentType) {
res.setHeader('Content-Type', contentType || 'text/plain');
res.writeHead(200);
res.end(content);
}

switch (req.url) {
case '/':
log('http: GET /');
sendText(
`<h1>Trigger Endpoints</h1>
<ul>
<li>Trigger photo: <a href="${baseUrl}/commands/start-picture" target="_blank">${baseUrl}/commands/start-picture</a></li>
<li>Trigger collage: <a href="${baseUrl}/commands/start-collage" target="_blank">${baseUrl}/commands/start-collage</a></li>
</ul>`,
'text/html'
);
break;
case '/commands/start-picture':
log('http: GET /commands/start-picture');
if (triggerArmed) {
photoboothAction('picture');
sendText('TAKE PHOTO TRIGGERED');
} else {
sendText('TAKE PHOTO ALREADY TRIGGERED');
}

break;
case '/commands/start-collage':
log('http: GET /commands/start-collage');
if (triggerArmed) {
photoboothAction('collage');
sendText('TAKE COLLAGE TRIGGERED');
} else {
sendText('TAKE COLLAGE ALREADY TRIGGERED');
}

break;
default:
res.writeHead(404);
res.end();
}
};

const http = require('http');
const server = new http.Server(requestListener);

/* CONFIGURE WEBSOCKET SERVER */
const ioServer = require('socket.io')(server, {
cors: {
origin: '*',
methods: ['GET', 'POST']
Expand Down Expand Up @@ -157,7 +208,9 @@ ioServer.on('connection', function (client) {
});

/* STARTUP COMPLETED */
log('socket.io server started');
server.listen(config.remotebuzzer.port, () => {
log('socket.io server started');
});

/*
** GPIO HANDLING
Expand Down