Giter Site home page Giter Site logo

shellysharp's Introduction

ShellySharp

ShellySharp is an object-mapper for shelly.io-devices

Currently these project is in a very early state. Please contact me if you have any suggestions or if you want to me to integrate more devices

Supported devices

  • Shelly 2.5 (read properties, switch on, switch off, toggle)
  • Shelly Dimmer 2 (switch on, switch off)

Authentication

  • at this time not implemented

NuGet-Package

Example Code

List<string> devices = new List<string> { "http://192.168.178.104", "http://192.168.178.105" };
devices.ForEach(devString =>
{
    string type = ShellySharp.Discover.GetDeviceInformation(devString).Type;

    switch (type)
    {
        case "SHSW-25":
            Shelly25 shelly = new Shelly25(devString);
            
            // register an eventlistener
            shelly.RelaySwitched += Shelly_DeviceSwitched;
            
            shelly.Relays[0].SwitchOn();
            Console.WriteLine(string.Format("Relay state is: {0}", shelly.Relays[0].Ison));
            Thread.Sleep(5000);
            shelly.Relays[0].SwitchToggle();
            Console.WriteLine(string.Format("Relay state is: {0}", shelly.Relays[0].Ison));
            Thread.Sleep(5000);
            shelly.Relays[0].SwitchToggle();
            Console.WriteLine(string.Format("Relay state is: {0}", shelly.Relays[0].Ison));
            Thread.Sleep(5000);
            shelly.Relays[0].SwitchOff();
            Console.WriteLine(string.Format("Relay state is: {0}", shelly.Relays[0].Ison));
            
            break;
         case "SHDM-2":
            ShellyDimmer2 shdm2 = new ShellyDimmer2(devString);
            shelly.LightSwitched += Shelly_DeviceSwitched;
            
            shdm2.Lights[0].SwitchOff();
            Console.WriteLine(string.Format("Relay state is: {0}", shdm2.Lights[0].Ison));
            Console.WriteLine("Press any key");
            Console.ReadKey();
            shdm2.Lights[0].SwitchOn();
            Console.WriteLine(string.Format("Relay state is: {0}", shdm2.Lights[0].Ison));
            Console.WriteLine("Press any key");
            Console.ReadKey();
            
            break;
        case "ANY_OTHER":
        default:
            break;
    }
});


private static void Shelly_DeviceSwitched(object sender, DeviceSwitchedEventArgs e)
{
    Console.WriteLine("{0} wurde auf '{1}' gestellt.", e.Device.Hostname ,e.IsOn);
}
    

shellysharp's People

Contributors

bmachuletz avatar 1kyg-xxxl avatar

Stargazers

 avatar Steve Celius avatar

Watchers

Daniel Zarins avatar Sebastian Dohrendorf avatar Steve Celius avatar  avatar

Forkers

lenwen evest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.