Skip to content

Instantly share code, notes, and snippets.

View benjaminrau's full-sized avatar

Benjamin Rau benjaminrau

View GitHub Profile
@benjaminrau
benjaminrau / Readme.md
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
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)
<?php
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
benjaminrau / InvalidateTokenEventListener.php
Last active May 19, 2021 19:57
Mechanism to invalidate JWT for specific User in Symfony with Lexik JWT Bundle
<?php
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
benjaminrau / ItemJsonNormalizer.php
Last active December 13, 2019 20:44
Allow to have different serialization groups for root resource and embedded relations
<?php
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
benjaminrau / Controller.php
Last active October 10, 2019 13:07
Fill ObjectStorage from QueryResult
$objectStorage = $this->fillOjectStorageFromQueryResult($this->myRepository->findAll()));
/**
* Fill objectStorage from QueryResult
*
* @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $queryResult
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
protected function fillOjectStorageFromQueryResult(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $queryResult=NULL) {
@benjaminrau
benjaminrau / gist:9896177
Created March 31, 2014 16:25
Access Media Files related to TYPO3 pages / FAL on page properties
{v:resource.record.fal(record: page, field: 'media', table: 'pages') -> v:iterator.extract(key: 'id') -> v:iterator.first() -> v:var.set(name: 'pageMedia')}
<f:if condition="{pageMedia}">
<v:page.header.meta name="og:image" content="{f:uri.image(src: pageMedia, treatIdAsReference: 1) -> v:format.prepend(add: '{v:page.siteUrl() -> v:format.substring(length: \'-1\')}')}" />
</f:if>
@benjaminrau
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: http://www.burocratik.com
*/
var isOutdatedBrowser = function(lowerThan) {
//assign css3 property or js property to IE browser version
if (lowerThan == 'IE8' || lowerThan == 'borderSpacing') {
@benjaminrau
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
<?php
namespace AppBundle\Annotation\Xss;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
/**
* @Annotation
* @Target({"PROPERTY"})
*/
<?php
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
benjaminrau / In Array Viewhelper
Last active September 26, 2017 19:22
An ViewHelper for extbase/fluid equivalent to php´s in_array() function.
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Benjamin Rau <rau@codearts.at>, codearts
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is