Today I took some first steps to control my Shelly 2.5 device. Actually, it’s about developing a class library for the Shellys in C # for my little smart home broker. In order to understand how the device works, an efficient script language such as Powershell is a good choice. Here is a small script to switch a Shelly 2.5 on and off, which is configured as a “relay”.
$myShellyIp = "192.168.178.104"; $myShellyState = (Invoke-WebRequest -Method GET http://$myShellyIp/relay/0).Content | ConvertFrom-Json; $myShellyState; # switch on relay 0 = ON # the returned content indicates that the shelly is now ON $myShellyStateOn = (Invoke-WebRequest -Method GET http://$myShellyIp/relay/0?turn=on).Content | ConvertFrom-Json; $myShellyStateOn; Start-Sleep -Seconds 5; # switch on relay 0 = OFF # the returned content indicates that the shelly is now OFF $myShellyStateOff = (Invoke-WebRequest -Method GET http://$myShellyIp/relay/0?turn=off).Content | ConvertFrom-Json; $myShellyStateOff;