• Amazing Broadlink Mini R3 with Google Home

    I have just configured a Broadlink Mini R3 to be used within Google Home’s scenario to control several devices. Works really like a charm !

    Click to Read More

    It’s just amazing that this little device can perfectly remote control my projection screen 7 meters away, the projector 2 meters away on the ceiling and the ampli which is in the room but not in sight.

    I bought 3 of them from China for 13€ each.

    Quick memo about how to configure them:

    • First step, install the App “ihc for EU” (special version compatible with GDPR for EU) to detect the device, assign it to the right room and add appliances (either from the library available out of the box or custom ones)
      • Attention: if you change later the room assigned to the RM mini 3 in the app, you loose all the appliances configured with it.
    • Next, configure some scenes to be used via Google Home. Their name will be used by Google Assistant.
    • Then, make the mini R3 accessible via your Google Assistant : Go to “Google Home” and “click Add” > “Setup a device” > “Works with Google”. There, link your “BroadLink Smart Home for EU” account with Google Home
    • Finally, use ‘in french’ : “Ok Google, active {le|la|l’} <xxx>” where <xxx> is the name of a scene and “le”, “la”, .. is optional
    Google Home Add Device
    Google Home Add Device

    Tip:

    • use “Ok Google, synchronise les appareils” to refresh the name of the scene in Google Home if you did rename them in the “ihc” app.
    • use scenario (“routines”) in Google Home to combine “IFTTT actions”, “scenes of other products like Philips Hue” and scenes from “Broadlink”.

    Using the “ihc” app, you can update the firmware: click on the RM mini > the three dot in the top-right corner > “Check for firmware updates”

    To configure an appliance, don’t hesitate to use one which does not work perfectly. At least, you will have all the related icons and be able to reconfigure them. Creating a “UserDefine” appliance, you won’t have many different icons available. Also, the configuration of  “UserDefine” appliance can’t be “backuped”. Not problem however to use “UserDefine” appliances in “scenes” to be called from Google Home.

    Once an appliance added, you can reconfigure the buttons: click on the appliance > the three dot in the top-right corner > Learn

    Don’t forget to backup the settings of your appliances once reconfigured!!! It’s the best ways to reuse them on other RM mini later: click on the appliance > the three dot in the top-right corner > Backup IR code sets

    Loading

  • Easily connect Ikea Tradfri bulbs on Philips Hue Bridge

    I did spent a lot of time trying to connect Smart/Cheap Ikea bulbs on my Philips Hue Bridge.

    I finally found an easy way: use the Android App HueDynamic !

    Click to Read More

    First, you must be sure to have Ikea Tradfri bulbs with a firmware >= 1.2.x

    To be sure about the firmware of Ikea bulbs, no choice but buy the Ikea Bridge and at least one Ikea Remote, then connect the bulb to the Android App “Tradfri”. If the firmware is obsolete, then the App can be used to trigger an update. But my experience is that even to connect the Ikea bulbs with their App, it’s a real pain in t…. Also, before connecting next the bulbs to the Philips Hue Brige, you will have to disconnect them from any Ikea remote and from to the App “Tradfri” (Check here).

    An option is however to check the batch id of the production, on the box. It is said that all bulbs produced with a batch id equal or above 1721 should have a firmware compatible with the Philips Hue Bridge.

    Here a sample of Ikea bulbs with a batch id 1733. I bought 6 of those and had (nearly) no issue to connect them.

    Ikea Tradfri Batch Id
    Ikea Tradfri Batch Id

    Once you have a bulb with adhoc firmware, turn it on and place it very close to your Philips Hue Bridge (less than 2 cm ;). The easiest for that is to use a cable like this one (I did one myself):

    Cable with adapter E14
    Cable with adapter E14           

    The bulb being on and next to the Hue Bridge, open the App HueDynamic and click on the three horizontal lines in the upper-left corner to open the menu. Then scroll down to the “Settings” section and pick the entry “Lights”:

    Click on the sign +, in the top-right corner to add the bulb:

    And select the option “With TouchLink” (This is the magic trick !!):

    Now, press the “TouchLink” button of your Philips Hue Bridge:

    The App HueDynamic will search for the bulb during 1 or 2 minutes… Once in touch with the bulb, this one will start to dim and bright several times before finally turning off. The App will continue to search for several minutes (for other bulbs) after that. When it stops to search, you see the bulb found on the screen. Accept it !

    Notice that this process failed for one of my bulb (out of 6). I tried twice and got each time the message here under:

    But when I came back to the list of bulbs, I saw that the bulb was actually in the list (Maybe I did something wrong without noticing ?!).

    Since the bulbs are connected, I have been able to combine them into rooms and control them with Philips Hue Motion Sensors. They work great so far !

    NB.: I read that Ikea remotes may not be used as once connected to a bulb, the bulb disappear from the Philips Hue Bridge… I didn’t try that yet and won’t 😉

    Loading

  • Reinstall Apps, Themes and Watch faces purchased on Samsung Galaxy Story

    After reinstalling my Gear S2 to connect it with a new Galaxy phone, I couldn’t find how to reinstall watch faces bought years ago.

    This can be done using the “Galaxy Store” app.

    Click to Read More

    1. “Galaxy Store” is an app preinstalled on Galaxy phones. Open it (Configuring your Samsung account if not yet done).
    2. Tap the 3 vertical dots on top right of screen
    3. Select “My page” (previously named “My Apps”).
    4. Select “All”
    5. Select the Watch, Apps or Themes
    6. Then re-download what you wish.

    To manage your Watch, install the “Galaxy Wearable ” App (previously named Galaxy Gear) via the Google App Store.

    Loading

  • Tips and tricks in French to use Philips Hue via Google Home

    Here is a list of a few tips & tricks to use the Bulbs of Philips Hue with a French Google Assistant.

    Click to Read More

    Important notice: based on my experience, Google Assistant is evolving fast (possibly learning). Meaning that at the beginning, only specific and correct sentences were supported.

    After some time, Google Assistant accept more flavor of those sentences.

    Synchronize Google Home and Philips Hue to see new Bubbles

    Prerequisite: link Google Home with your Philips Hue account.

    Reminder: Open the “Google Home” App. In the top part of the screen, there are various icons under the name of your house: “Eteindre” (Off), “Allumer” (On), “Lire” (Play) , “Ajouter” (Add), “Paramètres” (Settings) …. Click on “Ajouter” (Add) >  “Configurer un appareil” > “Fonctionne avec Google”. This is opening a screen to manage the linked accounts. Philips Hue must be added.

    Assuming that you have already linked Google Home with your Philips Hue account, when you add bubbles via the Philips Hue App, they don’t appear immediately in Google Home. To force Google Home to sync with Philips Hue, say “Ok Google” or “Dis Google”. Then “Mets à jour les lumières”, “Mets à jour les lampes” or “Synchronise les appareils”.

    [04/2019] It’s quite weird but initially the following sentences didn’t work: “Mets à jour les appareils”, “Synchronise les lumières”, “Synchronise les lampes”. Google was answering that you have to use Google Home for that… But after a few weeks, it started to work. It was not the first time that I notice this kind of “progress” with various commands. It’s seems that there is a kind of learning curve for the Google Assistant !

    Turn on/off Philips Hue’s lights

    Initially, I was only able to tell:

    • “Allume/éteins (le) X”, where X is the name of a light (Ex.: “Spot 1”, “Spot de Klara” – Notice that the names of my lights are not prefixed with an definite article ‘the’. So I can say “Allume le spot 1” or “Allume spot 1”).
    • “Allume/éteins (le) X à x%”,  where x is the percentage or luminosity
    • “Allume/éteins les lumières (de/du) X”, where X is the name of a room, to turn on/off all the lights in that room (Ex.: “Chambre de Klara”, “Bureau” – Notice that the names of my rooms are not prefixed with an definite article ‘the’).
    • “Allume/éteins les lumières (de/du) X à x%”, where x is the percentage or luminosity
    • “Allume/éteins les lumières” to turn on/off all the lights in the current room (I.e.: the room where the Google Assistant is assigned)
    • “Allume/éteins les lumières à x%”, where x is the percentage or luminosity

    Now, a bit confusing as not 10% consistent:

    • “Allume”, is going to turn on all the devices in the room, not only the light. In my case it also turn on Nvidia Shield TV
    • “Éteins”, does not work
    • “Allume/Éteins tout” turn on/off all the lights in the current room (I.e.: the room where the Google Assistant is assigned)
    • “Allume/Éteins tout dans (le/la) X” where X is the name of a room, to turn on/off all the devices in the current room (I.e.: the room where the Google Assistant is assigned)

    I also tried to use the word “lampes” instead of “lumières” but this was not recognized. I discussed that issue with Google Support. They told me that this was possibly due to the fact that the name of some lights used to be “lampe XYZ”. I did rename my lamps but without success at that time. Now, weeks later, it works. I can tell “Allume/éteins les lumières …” or “Allume/éteins les lampes …”. So, my experience is that the overall experience is not always consistent.

    Use Philips Hue Scenario

    To start a scenario named X, use the sentence “Active X”. Ex.: “Active Color Loop”

    To stop it, use the sentence “Désactive X” or “Stop X”

    Turn off and on only some Bubbles in a room using Philips Hue Scenario

    With Google Home, it’s currently not possible to create several groups of Bubbles in a room. It’s also not possible to include a Bubble within several rooms (if you want to use fake rooms to group your bubbles). But as a trick, you can create a “Scenario” within the Philips Hue App (Scene) to turn off or on any subset of Bubbles.

    Open the Philips Hue App and tap the room containing the Bubbles to group. Once the room opened, tap “Nouveau Scénario” (New Scene).

    On the color picker (color or white disc), you see your lamps (a bubble or small circles with the amount of bubbles, one bubble or circle per type of lamp – color or white). Tap the circle representing several bubbles to access each bubble individually and define its rightness or its state on/off in the Scene. You can decide to have x lights on, y lights off and z lights dimmed to 50%.

    Name that new scene like “les lumières XYZ” (the lights XYZ). Once Google Home and Philips Hue synchronized, you will be able to tell “Ok Google”, “Active les lumières XYZ” (Activate the lights XYZ).

    Combine commands into a routines [03/2019]

    I did create routines to combine commands into a sequence, with sometimes delays between each commands. Ex.: to turn on all the devices to watch a movie, I simply say “Ok Google, allume le cinéma”. The routine is a set of individual commands to turn on the projector, turn on the console NVidia and open the projection screen: “active l’allumage du projecteur”, “allume shield”, “active l’ouverture d’écran”.

    “active l’allumage du projecteur” and “active l’ouverture d’écran” are two scénario define in my Broadlink account (to remote control devices via IR: See this note). As those are accessing scenario via services, we have to use the verb “active”.

    “allume shield” is a native command of Google Home. Indeed, no need to integrate any service to remote contro a NVidia Shield TV. But keep in mind that there are plenty of issues with remote controlling Shield: can open Netflix, but can’t start a movie. the volume is decreased each time you tell a command but is not restored to its initial level once the command executed, etc…

    Command Somfy blinds with Tahoma box [04/2019]

    In the past, I used to control blinds motorized with Somfy via voice commands thanks to the integration between Google Home and the Tahoma box via IFTTT.

    Now, thanks to the native integration of “Somfy Tahoma & Connexoon” services with Google Home, I could get rid of IFTTT to control the blinds.

    Here are the supported sentence once all devices are assigned to rooms in Google Home:

    • “Ok Google, ouvre/ferme X” – X being the name of a blind (“store” or “volet” in Tahoma)
    • “Ok Google, ouvre/ferme X à x %”

    X can have articles but Google Assistant will quickly learn that there are various flavor possible: “le volet du salon”, “le volet au salon”, “mon volet du salon”.

    To close all the blinds, I was only able to do it for sure with

    • “OK Google, ouvre/ferme tout” to close all blind in the home
    • “OK Google, ouvre/ferme tout dans X” to close all blinds in a room named X. Another way is to tell :” Ok Google, ouvrir X”. This is not a nice French sentence and seems a direct translation of the English version. Notice that if X = “Bureau”, you won’t be able to tell “Ok Google, ouvrir le Bureau”. To do that, the room must be named “le Bureau” instead of simple “Bureau”.

    Although the documentation of Tahoma pretends that we should be able to tell “OK Google, ouvre/ferme tous les volets” to close all the blinds in the current room (room where the Assistant is assigned), this does not work. Also notice that you may not open the door of the Garage due to Google security Policy applied on the integrated services. You may only do it via IFTTT !!!

    use several commands and/or routines together

    I discovered by accident that Google Home was supporting sentences combining several commands X, Y, Z …, simply by telling “Ok Google, X et Y et Z …”. Ex.:

    • “Ok Google, allume le cinéma et ferme tout dans le bureau” where “allume le cinéma” and “ferme tout dans le bureau” are two distinct routines.
    • “Ok Google, allume le cinéma et ferme tout dans le bureau et éteins tout” where “allume le cinéma” and “ferme tout dans le bureau” are two distinct routines.

    Loading

  • Capture a Synology Package during installation

    This is an update of a previous post on this topic.

    I noticed that since a recent update of DSM, my previous script was not working fine anymore, when trying to capture a spk during installation. So here is an improved version.

    Click to Read More

    [code language=”bash”]

    #!/bin/bash
    VOLUME=$1
    TARGET=$2

    #Copy also the expanded package ?
    COPYEXPAND=false

    if [ -z &quot;$VOLUME&quot; ]; then
    echo &quot;usage: capture &lt;source VOLUME&gt; &lt;target dir&gt;&quot;
    exit 0
    fi

    if [ -z &quot;$TARGET&quot; ]; then
    echo &quot;usage: capture &lt;source VOLUME&gt; &lt;target dir&gt;&quot;
    exit 0
    fi

    pattern=&quot;volume[0-9]+&quot;
    if [[ ! $VOLUME =~ $pattern ]]; then
    echo &quot;The name of the source volume must be like ‘volume&lt;i&gt;’ where &lt;i&gt; is numeric&quot;
    exit 0
    fi

    if [ ! -d &quot;/$VOLUME/@tmp&quot; ]; then
    echo &quot;Temporary dir not found: /$VOLUME/@tmp&quot;
    exit 0
    fi

    if [ -d &quot;/$VOLUME/@tmp/SynoCapture&quot; ]; then
    rm -R &quot;/$VOLUME/@tmp/SynoCapture&quot;
    fi

    if [ -d &quot;/$VOLUME/@tmp/@synopkg&quot; ]; then
    rm -R &quot;/$VOLUME/@tmp/@synopkg&quot;
    fi

    echo &quot;Press any key to stop the capture&quot;

    if [ -t 0 ]; then stty -echo -icanon -icrnl time 0 min 0; fi

    count=0
    keypress=”
    echo &quot;Going to copy the packages into $TARGET/SynoCapture&quot;

    if [ ! -d &quot;$TARGET/SynoCapture&quot; ]; then
    mkdir &quot;$TARGET/SynoCapture&quot;
    fi

    while [ &quot;x$keypress&quot; = &quot;x&quot; ]; do
    if [ -d &quot;/$VOLUME/@tmp/@synopkg/@download/&quot; ]; then
    cp -nlR &quot;/$VOLUME/@tmp/@synopkg/@download/.&quot; &quot;/$VOLUME/@tmp/SynoCapture/&quot;
    fi

    if [ &quot;$COPYEXPAND&quot; = true ]; then
    if [ -d &quot;/$VOLUME/@tmp/pkginstall/&quot; ]; then
    cp -nlR &quot;/$VOLUME/@tmp/pkginstall/.&quot; &quot;/$VOLUME/@tmp/SynoCapture/pkginstall/&quot;
    fi
    fi
    let count+=1
    echo -ne $count’\r’
    keypress=&quot;`cat -v`&quot;
    done

    if [ -t 0 ]; then stty sane; fi

    find &quot;/$VOLUME/@tmp/SynoCapture/&quot; -type f -name ‘@SYNOPKG_DOWNLOAD_*’ -exec sh -c ‘x=&quot;{}&quot;; mv &quot;$x&quot; &quot;${x}.spk&quot;’ \;
    if [ &quot;$COPYEXPAND&quot; = true ]; then
    if [ -d &quot;$TARGET/SynoCapture/pkginstall&quot; ]; then
    rm -R &quot;$TARGET/SynoCapture/pkginstall&quot;
    fi
    fi
    cp -fR &quot;/$VOLUME/@tmp/SynoCapture&quot; &quot;$TARGET/&quot;
    rm -R &quot;/$VOLUME/@tmp/SynoCapture&quot;

    echo &quot;$count captures done&quot;
    exit 0

    [/code]

    Now the script will copy only the SPK file into the specified target folder. It’s also possible to copy the expanded version by setting the variable COPYEXPAND=true

    Also, now, I don’t find anymore a folder name “pkglist.tmp” containing files synoserver.enu and otherserver.enu. Those files used to contain the URL’s of all SPK available respectively on the official Synology website and on the various SPK servers that you configured in your Package Center > Settings > Package Sources.

    To make the capture even easier, I have create a Package named “MODS Package Capture, available on my SPK Server and published on GitHub.

    Loading

  • Can’t install/uninstall/repair Synology Virtual Machine Manager – Upgrade DSM not possible

    I was unable to upgrade my DSM from 6.1.7 to 6.2.1 because it was pretending to be member of a Virtual Machine Manager cluster. Which was not correct as Virtual Machine Manager was not installed ‘anymore’.

    Click to Read More

    I used to test the beta version of Virtual Machine Manager a long time ago. But since a while, Virtual Machine Manager is not installed anymore on my Synology and it was clearly visible neither in the DSM menu nor in the Package Center.

    Unfortunately, for some unknown reasons, my DSM thought that it was still part of Virtual Machine Manager cluster. As a consequence I was getting the following warning when upgrading my DSM: “This device is part of a Virtual Machine Manager cluster. Other hosts in the Virtual Machine Manager cluster will also need to be updated“.

    Trying to upgrade was always failing (without breaking my DSM, fortunately).

    I initially thought it could possibly be due to the network Bond I did create. So I tried to remove it via Control Panel > Network. But it failed with the message : “Creating or deleting this bond is prohibited because the operating interfaces includes the cluster interface of Virtualization. Please shutdown these quests and try again: {0}. Creating or deleting the bond is prohibited because of abnormal status of Virtualization cluster, please go to Virtual Machine Manager see the details.”

    Based on this message, and since it was not installed anymore, I tried to reinstall the Virtual Machine Manager. Unfortunately, the installation was failing and the package was stuck in a “repair” status.

    Being unable to ‘repair’ it by clicking on the “Repair” button, I tried to uninstall it. This was also failing, with the following message: “You cannot remove this package because this Synology NAS is a part of a Virtual Machine Manager Cluster. Please remove the host from the cluster to proceed.”

    Argh !!!

    Bref… I tried to ‘erase’ the package using my own Package Manager (See my SSPK server). It’s doing something similar to the trick explained here to delete all files related to the ‘Virtualization’ package.

    Once the package fully erased, I did reinstall it again but still without any success… And again it was stuck in a “repair” status and I was unable to uninstall it properly.

     

    As I couldn’t find any config file where I could see that my NAS was a member of a Virtual Machine Manager cluster, I tried to fix myself the installation of the package. I couldn’t really fix it (I couldn’t see which step of which installation or upgrade script was failing). But I have been able to force the installation to complete by deleting the file ‘/var/packages/Virtualization/installing’.

    Next, the package Virtual Machine Manager appeared in status ‘Installed’ but ‘stopped’. I was however able to “Start” it without any problem !! I could see in this Manager that my NAS indeed used to be configured as a member of cluster.

    And, miracle (even without deleting the cluster), running now the upgrade of my DSM finally succeeded !!!

    After the upgrade, I did remove my NAS from the cluster.

    Et voilà.

    [PS] I did use the Virtual Machine Manager a long time ago to test how Windows was running in a VM. It was a bit too slow for me so I did remove the Virtual Machine Manager. Probably that the cluster was not deleted at that time. Hence all the problems here above.

    [Edit] Once the DSM upgraded, I did delete the Virtual Machine Manager cluster. But as a consequence, I did lost all connections onto the NAS (ftp, web, plex, ssh, …). I was only able to see the NAS using the Synology Assistant. TO solve the problem I did shutdown the NAS by pressing the power button for a long period. After the reboot, everything as working fine. No, starting the Virtual Machine Manager, it starts a wizard to create a new cluster.

    Loading

  • Search for file on Linux using grep and find

    Search for files containing a certain text, on my Synology, ignoring warnings like ‘ Permission denied’

    Click to Read More

    Just a note for myself… as I always forgot the syntax :/

    Using grep only

    grep -rnlw ‘/path/to/somewhere/’ -e ‘pattern’ 2>/dev/null

    grep -rnlw ‘text’ ‘/path/to/somewhere/’ 2>/dev/null

    • -r or -R is recursive,
    • -n is line number, and
    • -w stands for match the whole word.
    • -l (lower-case L) can be added to just give the file name of matching files.

    Using find

    find ‘/path/to/somewhere/’ -type f -exec grep “text” ‘{}’ \; -print

    Loading

  • Find and kill all tasks running for a service/package on a Synology

    I wanted to kill all tasks running on my Synology for a package before uninstalling this one. Here is the how-to:

    Click to Read More

    The tasks running for a service are all listed in /sys/fs/cgroup/cpuacct/[the service]/tasks

    The service can be pgsql, nginx, nmbd, ftpd, sshd, … or synotifyd, synologd, synobackupd, … or a package like pkgctl-CloudSync, pkgctl-AudioStation, pkgctl-SurveilanceStation, …

    Ex.:

    • To see all tasks running for Synology’s StorageAnalyzer, type something like: cat /sys/fs/cgroup/cpuacct/pkgctl-StorageAnalyzer/tasks
    • To kill all those tasks, type something like: for task in $(cat /sys/fs/cgroup/cpuacct/pkgctl-StorageAnalyzer/tasks); do kill $task; done

    Loading

  • License and installation wizard not shown when installing Synology Package

    I noticed this morning that my Synology is not showing the License and the Installation Wizard anymore when installing my own Packages (Packages made with my app MODS and hosted on my own SSPK Server).

    Click to Read More

    I am not yet able to understand why the Installation Wizards and the Licence file of my own packages are not shown anymore, when installing them from my SSPK server via “Package Center” > “Community”. But everything works fine when installing them “Manually” via “Package Center” > “Manual Install” (and browsing to pick the spk into the folder of my SSPK server).

    The Upgrade Wizards and even the “Confirm settings” screen are also not displayed… While the Uninstallation Wizard works fine in all cases ?!

    My DS1815+ is running DSM 6.1.7-15284.

    I have compared all the logs created in /var/log/ during the installation and noticed a few differences. First, when installing a package from my SSPK server, there are ‘messages’ being logged:

    2018-11-03T22:26:05+01:00 … synoscgi_SYNO.Core.Package.Installation_1_install[21663]: resource_api.cpp:163 Acquire service-cfg for [the package I am installing] when 0x0001 (done)

    This is logged each time I am installing a package from my SSPK Server but not when install the same package manually.

    Next to those messages, the following INFO are also logged in synofeasibilitycheck.log:

    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:87 FeasibilityCheck: [Info] Start feasibility check [package_install] with type [hard].
    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:106 FeasibilityCheck: [Info] [0] of feasibility check [package_install] failed.
    2018-11-03T22:25:50+01:00 … synoscgi_SYNO.Core.Package_1_feasibility_check[21529]: feasibility_check.cpp:79 FeasibilityCheck: [Info] No [package_install] feasibility check config with type [soft].

     

    Loading

  • Call a php webpage from a IFTTT applet using Google Assistant

    I wanted to be able to wake up PC on my Lan using voice commands. To achieve that, I did implement a solution using Google Assistant, IFTTT and a php web page hosted on my NAS.

    Click to Read More

    Regarding IFTTT, you must have an account. Then,

    • Create a new applet,
    • Choose the service “Google Assistant”
      • Choose a trigger, ex.: “Say a phrase with a text ingredient”
      • Type a phrase in “What do you want to say?” such as “Wake up my PC $” ($ is the symbol to be used for the “ingredient”)
      • Type a phrase in “What do you want the Assistant to say in response?” such as “Ok, I will wake up $”
    • Choose next an action service “Webhooks” (to “make a web request”)
      • Type the url of your web page: http://<public Ip of your NAS>/<some path>/action.php?do=wakeup&param={{TextField}} ({{TextField}} will take the value of the ingredient)
      • Chose the “method”: GET
      • Chose the “content type”: text/plain

    Regarding the php web page (action.php), I had to do some fine tuning… So, I started with a page logging all information received from IFTTT:

    [php]</pre>
    <?php
    // https://gist.github.com/magnetikonline/650e30e485c0f91f2f40
    class DumpHTTPRequestToFile
    {
    public function execute($targetFile)
    {
    $boby = json_decode(file_get_contents(‘php://input’) , true);

    $data = sprintf("<h2><u>IFTTT call at %s on %s</u></h2><h3>Method:</h3>", date(‘h:i:s’) , date(‘d/m/Y’));
    $data .= sprintf("<blockquote>%s (%s): %s </blockquote><h3>HTTP headers:</h3><ul>", $_SERVER[‘REQUEST_METHOD’], $_SERVER[‘SERVER_PROTOCOL’], htmlentities($_SERVER[‘REQUEST_URI’]));
    foreach ($this->getHeaderList() as $name => $value)
    {
    $data .= "<li><b>" . $name . ‘</b>: ‘ . $value . "</li>";
    }

    $data .= "</ul><h3>Post:</h3><ul>";
    foreach ($_POST as $key => $value) $data .= "<li>" . $key . ‘=’ . $value . ‘</li>’;

    $bodyhtml = $this->jsonToTable($boby);
    $data .= "</ul><h3>Request body:</h3><blockquote>$bodyhtml</blockquote>";

    $action = trim(strtolower($_GET[‘action’]));
    $action = preg_replace(‘/^ *de +/’, ”, $action);
    $action = preg_replace(‘/^ *d *\’ +/’, ”, $action);

    $param = trim(strtolower($_GET[‘param’]));
    $param = preg_replace(‘/^ *de +/’, ”, $param);
    $param = preg_replace(‘/^ *d *\’ +/’, ”, $param);

    $data .= "<h3>Requested Action:</h3><blockquote>$action: $param</blockquote>";

    similar_text(strtolower($param) , "zeus", $percent);
    $data .= "Zeus: $percent %<br>";

    similar_text(strtolower($param) , "chaos", $percent);
    $data .= "Chaos: $percent %<br>";

    file_put_contents($targetFile, $data . file_get_contents($targetFile) . "\n");

    echo (nl2br($data));
    }

    private function getHeaderList()
    {
    $headerList = [];
    foreach ($_SERVER as $name => $value)
    {
    if (preg_match(‘/^HTTP_/’, $name))
    {
    // convert HTTP_HEADER_NAME to Header-Name
    $name = strtr(substr($name, 5) , ‘_’, ‘ ‘);
    $name = ucwords(strtolower($name));
    $name = strtr($name, ‘ ‘, ‘-‘);
    // add to list
    $headerList[$name] = $value;
    }
    }
    return $headerList;
    }

    private function jsonToTable($data)
    {
    $table = "<table class=’json-table’ width=’100%’>";
    foreach ($data as $key => $value)
    {
    $table .= "<tr valign=’top’>";
    if (!is_numeric($key))
    {
    $table .= "
    <td>
    <strong>" . $key . ":</strong>
    </td>
    <td>
    ";
    }
    else
    {
    $table .= "
    <td colspan=’2′>
    ";
    }
    if (is_object($value) || is_array($value))
    {
    $table .= jsonToTable($value);
    }
    else
    {
    $table .= $value;
    }
    $table .= "
    </td>
    </tr>
    ";
    }
    $table .= "</table>";
    return $table;
    }
    }

    (new DumpHTTPRequestToFile)->execute(‘./action.html’);

    ?>
    <pre>[/php]

    The log is stored in a html page “log.html”.

    Notes:

    • I notice that Google was not good at recognizing the name of my PC (IMO because I use French sentences). So I am using a php command “similar_text” to evaluate the “ingredient”. But this is really far from effective.
    • I tried to use a “POST” method instead of “Get” and a Content Type “application/json”, it works. But when I add a Body like {“token”:”mseries”,”command”: “<<<{{TextField}}>>>”, ”test”: “data”}, I don’t see it received by my php page 🙁
    • If Google Assistant does not call correcly IFTTT, look at you voice command history to be sure it understood you order: https://myactivity.google.com/myactivity?restrict=vaa&utm_source=help
    • If Google Assistant understood correctly your command, but IFTTT didn’t call your web page, look at your IFTTT activity: https://ifttt.com/activity

    A log for a call using a GET method will look like:

    IFTTT call at 11:32:29 on 25/09/2018

    Method: GET (HTTP/1.1): /ifttt/action.php?action=wakeup&param=CARROS

    HTTP headers:

    X-Newrelic-Transaction: PxQGUlECCwFRBVEEVQAAAlQTGlUDChAHHEAJVA1cAgMKA1gEVFNVUVUHFU1EAQACBV1UBlUTag==
    X-Newrelic-Id: VwAOU1RRGwAFUFZUAwQE
    Content-Type: text/plain
    Content-Length: 74
    Connection: close
    Host: olympe.letroye.be
    X-Real-Port: 55748
    X-Port: 80
    X-Real-Ip: 54.164.110.125
    X-Forwarded-By: 192.168.0.200

    Post:

    Request body:

    Requested Action: wakeup: CARROS

    Zeus: 20 %
    Chaos: 72.727272727273 %

    A log for a call using a POST method with application/json content-type will look like:

    IFTTT call at 11:41:14 on 25/09/2018

    Method: POST (HTTP/1.1): /ifttt/action.php?action=wakeup&param=Kaos

    HTTP headers:

    X-Newrelic-Id: VwAOU1RRGwAFUFZUAwQE
    Content-Type: application/json
    Content-Length: 77
    Connection: close
    Host: olympe.letroye.be
    X-Real-Port: 59892
    X-Port: 80
    X-Real-Ip: 54.211.16.53
    X-Forwarded-By: 192.168.0.200

    Post:

    Request body:

    Requested Action: wakeup: kaos

    Zeus: 25 %
    Chaos: 66.666666666667 %

    Loading

Tags


Acer iDea 510 AirPlay Android Backup DD-WRT DNS DS209+ DS713+ DS1815+ FlexRaid Galaxy Galaxy S2 Galaxy S7 Google Assistant Google Home HTPC Kies MCE MySQL Nabi 2 Nvidia TV Shield One Plus One OnePlus One OpenHab Outlook Philips Hue Plex RAID Raspberry PI Remote Desktop Root Access Samsung Scripts Synology Team Build Visual Studio VMWare Wi-Fi Windows Windows 8 Windows 8.1 Windows 10 Windows Server 2012 XBMC Xpenology

Categories


Archives