Skip to content

Instantly share code, notes, and snippets.

View benjaminrau's full-sized avatar

Benjamin Rau benjaminrau

View GitHub Profile
benjaminrau /
Last active March 12, 2024 09:15
Home Assistant (HASS) with Homekit, Television Volume Control and Fire TV Stick connected to Sony Bravia

Home Assistant (HASS) with Homekit, Television Volume Control and Fire TV Stick connected to Sony Bravia

Basically it integrates and older Sony Bravia TV with Fire TV Stick on HDMI via Home Assistant in Apple Homekit with Siri Voice Control for Volume, Mute and Turning TV on and off.

Features of my setup

  • Voice control for television on, off, mute, set volume, play, pause
  • Control for television on, off, mute, set volume and input (which app to start) in Home app
  • Turn on TV light scene when TV starts playing
  • iOS Remote Widget inputs are forwarded to media player & Android TV

Used Integrations

benjaminrau / InvalidateTokenEventListener.php
Last active May 19, 2021 19:57
Mechanism to invalidate JWT for specific User in Symfony with Lexik JWT Bundle
namespace Emma\UserBundle\EventListener;
use Doctrine\ORM\EntityManagerInterface;
use Emma\UserBundle\Entity\User;
use FOS\UserBundle\Event\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\HttpFoundation\JsonResponse;
benjaminrau / ItemJsonNormalizer.php
Last active December 13, 2019 20:44
Allow to have different serialization groups for root resource and embedded relations
namespace Emma\AppBundle\Serializer;
use ApiPlatform\Core\Util\ClassInfoTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
benjaminrau / outdatedBrowser.js
Last active February 7, 2019 08:55
Outdated Browser - minified to return just boolean
* Outdated Browser
* Version: 1.1.2 - 2015
* author: Burocratik
* website:
var isOutdatedBrowser = function(lowerThan) {
//assign css3 property or js property to IE browser version
if (lowerThan == 'IE8' || lowerThan == 'borderSpacing') {
namespace Emma\AppBundle\EventSubscriber;
use ApiPlatform\Core\EventListener\EventPriorities;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Emma\AppBundle\AppBundleEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
benjaminrau / AllowedTags.php
Last active July 30, 2018 18:03
XSS Protection - will remove all html tags onFlush (before they are persisted) from fields which are ORM type text or string, with option to define allowed html tags by annotation
namespace AppBundle\Annotation\Xss;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
* @Annotation
* @Target({"PROPERTY"})
benjaminrau / Emma_MediaBundle_EventListener_SerializeListener.php
Last active June 7, 2021 07:53
File Upload (JSON) and store with Sonata Media Bundle (based on ApiPlatform 2.0, Symfony 3.1)
namespace Emma\MediaBundle\EventListener;
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
use Emma\MediaBundle\Entity\MediaElement;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\Serializer\SerializerInterface;
benjaminrau /
Created April 6, 2016 15:34
Onion Omega with Adafruit Power Board 500 mA, shutting down the onion when battery is now or power disconnected
import sys, os, datetime
from gpiohelper import GPIOHelper
helper = GPIOHelper()
vInPin = 12
lowBatteryPin = 8
pinToCheck = vInPin;
durationOfNotOKInMinutesBeforeShutdown = 1
benjaminrau / main.js
Created March 18, 2016 23:22
Read gps device with nodejs under openwrt and cp2102 ttl to usb converter
var nmea = require('nmea');
var trycatch = require('trycatch');
function watchGps() {
var spawn = require('child_process').spawn;
var child = spawn("python", [tempDir + ""]);
child.stdout.on('data', function (buffer) {
trycatch(function() {
var gpsOut = nmea.parse(buffer.toString());
benjaminrau / Form.html
Last active January 25, 2016 16:25
HTML5 LocalStorage used to fill form
$(document).ready(function() {
function initFormStorage(registrationFormId) {
console.log('Initializing storage for form#' + registrationFormId);
* when a form field changes store it's value in local storage
$("#" + registrationFormId + " input[type=text], #" + registrationFormId + " select, #" + registrationFormId + " textarea").change(function() {
$this = $(this);
console.log('Update value for ' + $this.attr("name") + 'to ' + $this.val());