Skip to content

Instantly share code, notes, and snippets.

View blacklight's full-sized avatar

Fabio Manganiello blacklight

View GitHub Profile
#!/usr/bin/env python
### Get one or more true random numbers using the qrng.anu.edu.au quantum
### random number generator through the available API
### Author: Fabio <BlackLight> Manganiello
import argparse
import json
import requests
@blacklight
blacklight / nfcexec.py
Created December 27, 2018 10:54
Read content from NFC tags abd dispatch it as requests to Platypush
import json
import logging
import nfc
import ndef
import sys
import time
from redis import Redis
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
@blacklight
blacklight / request1.json
Last active July 26, 2019 14:52
[Medium] Platypush request example 1
{
"type":"request",
"action":"light.hue.on",
"args": {
"groups": [
"Living Room",
"Bathroom"
]
}
}
@blacklight
blacklight / request1.py
Created July 26, 2019 15:02
[Medium] Platypush request example 2
from platypush.context import get_plugin
response = get_plugin('light.hue').on(groups=['Living Room', 'Bathroom'])
print(response)
@blacklight
blacklight / request1.sh
Created July 26, 2019 15:07
[Medium] platypush request example cURL
# cURL example
curl -XPOST -H 'Content-Type: application/json' \
-d '{"type":"request", "action":"light.hue.on", "args": {"groups": ["Living Room", "Bedroom"]}}' \
http://localhost:8008/execute
# HTTPie example
echo '{"type":"request", "action":"light.hue.on", "args": {"groups": ["Living Room", "Bedroom"]}}' | http http://localhost:8008/execute
@blacklight
blacklight / request2.json
Created July 26, 2019 15:22
[Medium] platypush example request 2
{
"type":"request",
"action":"light.hue.get_lights"
}
@blacklight
blacklight / response1.json
Last active July 26, 2019 17:36
[Medium] platypush example response
{
"id": "6e5383cee53e8330afc5dfb9bde12a25",
"type": "response",
"target": "http",
"origin": "your_server_name",
"_timestamp": 1564154465.715452,
"response": {
"output": {
"1": {
"state": {
@blacklight
blacklight / event_hook.yaml
Created July 26, 2019 16:54
[Medium] platypush event hook example 1
# Play a specific radio on the mpd (or mopidy) plugin
event.hook.PlayRadioParadiseAssistantCommand:
if:
type: platypush.message.event.assistant.SpeechRecognizedEvent
phrase: "play (the)? radio paradise"
then:
action: music.mpd.play
args:
resource: tunein:station:s13606
@blacklight
blacklight / procedure_example_1.yaml
Created July 26, 2019 18:43
[Medium] platypush procedure example
# Note: procedures can be synchronous (`procedure.sync` prefix) or asynchronous
# (`procedure.async` prefix). In a synchronous procedure the logic will wait for
# each action to be completed before proceeding with the next - useful if you
# want to link actions together, letting each action access the response of the
# previous one(s). An asynchronous procedure will execute instead all the actions
# in parallel. Useful if you want to execute a set of actions independent from
# each other, but be careful not to stack too many of them - each action will be
# executed in a new thread.
procedure.sync.at_home:
- action: serial.get_measurement
@blacklight
blacklight / docstring.py
Created July 26, 2019 21:13
[Medium] platypush plugin docstring check example
>>> from platypush.context import get_plugin
>>> plugin = get_plugin('light.hue')
>>> print(plugin.__doc__)
Philips Hue lights plugin.
Requires:
* **phue** (``pip install phue``)