• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Shelly device
#1
Hi!

As 433 Mhz is always susceptible to RF interference, I am now experimenting with shelly-devices (https://shelly.cloud/).

This is a small relay unit, connected by WiFi, which can be placed behind a switch and connected to is. So the relay and the connected lamp  can be switched either by the physical switch or by http. I't is similar to Sonoff flashed with Tasmota. But you can use it out of the box without flashing. And most importent to me it can work without any cloud connection.

Because I already have a lot of 433 MHz-devices which will not all be replaced by shelly, I would like to mix 433 and shelly under the nice clean GUI of pilight.

I've now integrated the shelly by the following trick I found in the Forum. This are the relevant parts of my config
Code:
        "ShellyOn": {
            "protocol": [ "program" ],
            "id": [{
                "name": "ShellyOn"
            }],
            "program": "php /home/pi/ShellyOn.php",
            "arguments": "",
            "stop-command": "",
            "start-command": "php /home/pi/ShellyOn.php",
            "state": "stopped",
            "pid": 0
        },
        "ShellyOff": {
            "protocol": [ "program" ],
            "id": [{
                "name": "ShellyOff"
            }],
            "program": "php /home/pi/ShellyOff.php",
            "arguments": "",
            "stop-command": "",
            "start-command": "php /home/pi/ShellyOff.php",
            "state": "stopped",
            "pid": 0
        },
        "Hof": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 97
            }],
            "state": "off"
        },

Code:
        "HofAn": {
            "rule": "IF Hof.state == on THEN switch DEVICE ShellyOn TO running",
            "active": 1
        },
        "HofAus": {
            "rule": "IF Hof.state == off THEN switch DEVICE ShellyOff TO running",
            "active": 1
        },

The scripts to switch on and off are
Code:
<?php

printf( "Shelly.php Version 1.0.0 2019.02.23\n" );

//phpinfo();

$response = file_get_contents( "http://shelly-Hoflicht.fritz.box/relay/0?turn=on" );
printf( "Result=%s\n", $response );


?>
and
Code:
<?php

printf( "Shelly.php Version 1.0.0 2019.02.23\n" );

//phpinfo();

$response = file_get_contents( "http://shelly-Hoflicht.fritz.box/relay/0?turn=off" );
printf( "Result=%s\n", $response );


?>
As the shelly has the possibility to read out the actual state (indeprendent of switching physical of by http, I have a 3rd script to update pilight
Code:
<?php

printf( "Shelly.php Version 1.0.0 2019.02.23\n" );

//phpinfo();

$oldIson=false;
$newIson=false;

while( true )
{
    $response = file_get_contents( "http://shelly-Hoflicht.fritz.box/relay/0" );
//    printf( "Result=%s\n", $response );
    if ( strpos( $response, "\"ison\":true" ) == false )
        $newIson = false;
    else
        $newIson = true;
//    printf( "oldIson=%d newIson=%d\n", $oldIson, $newIson );
    if ( $newIson != $oldIson )
    {
        if ( $newIson )
        {
            printf( "Hoflicht angeschaltet\n" );
            $response = file_get_contents( "http://raspberrypi.fritz.box:5001/control?device=Hof&state=on" );
////            printf( "%s\n", $response );
        }
        else
        {
            printf( "Hoflicht ausgeschaltet\n" );
            $response = file_get_contents( "http://raspberrypi.fritz.box:5001/control?device=Hof&state=off" );
//            printf( "%s\n", $response );
        }
        $oldIson = $newIson;
    }
    sleep( 1 );
}

?>

So this is of course only quick and dirty and not really usable for a larger amount of shelly-devices. What I like to have is a new protocol with the URL and a poll-time for the update of external switch-events. Something like
Code:
        "Hof": {
            "protocol": [ "shelly_switch" ],
            "id": [{
                "URL": "xxx.xxx.xxx.xxx",
                "polltime": 1
            }],
            "state": "off"
        },
What would be necessary to implement this? Is in the c-part or in lua? I could write some code, but I'm normally developing for Windows and not used to the unix build chain
Uli
 
Reply
  


Messages In This Thread
Shelly device - by Ulrich.Arnold - 03-09-2019, 11:24 AM
RE: Shelly device - by curlymo - 03-09-2019, 04:57 PM
RE: Shelly device - by curlymo - 03-09-2019, 05:45 PM
RE: Shelly device - by Ulrich.Arnold - 03-09-2019, 05:58 PM
RE: Shelly device - by curlymo - 03-10-2019, 10:12 AM
RE: Shelly device - by Ulrich.Arnold - 08-16-2019, 04:45 PM
RE: Shelly device - by curlymo - 08-16-2019, 07:02 PM
RE: Shelly device - by Ulrich.Arnold - 08-16-2019, 09:19 PM
RE: Shelly device - by Ulrich.Arnold - 08-24-2019, 03:52 PM
RE: Shelly device - by curlymo - 08-24-2019, 04:34 PM
RE: Shelly device - by Ulrich.Arnold - 08-25-2019, 09:15 AM
RE: Shelly device - by Ulrich.Arnold - 08-27-2019, 05:24 PM
RE: Shelly device - by Ulrich.Arnold - 09-18-2019, 05:43 PM
RE: Shelly device - by curlymo - 09-18-2019, 06:17 PM
RE: Shelly device - by curlymo - 09-26-2019, 02:03 PM
RE: Shelly device - by Ulrich.Arnold - 09-26-2019, 03:23 PM
RE: Shelly device - by Ulrich.Arnold - 10-06-2019, 10:09 AM
RE: Shelly device - by curlymo - 10-06-2019, 10:17 AM
RE: Shelly device - by Ulrich.Arnold - 10-06-2019, 11:36 AM
RE: Shelly device - by curlymo - 10-06-2019, 12:19 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  re-recognition of device sending signals n0l0cale 1 525 02-21-2019, 12:30 PM
Last Post: TerryLewis

Forum Jump:


Browsing: 1 Guest(s)