Giter Club home page Giter Club logo

knx.net's Introduction

KNX.net build status NuGet version

KNX.net provides a KNX API for C#

This API allows to connect in both modes:

  • Tunneling
  • Routing

After connecting you will be able to send actions to the bus and receive messages from it.

The following datapoints are available in the API:

DPT input type input range output type output range Description
3.007 int, float, long, double, decimal [-7,7] int [-7,7] Control blinds (steps) [0 stops]
3.008 int, float, long, double, decimal [-7,7] int [-7,7] Control dimming (steps) [0 stops]
5.001 int, float, long, double, decimal [0,100] decimal [0,100] Percentage (%)
5.003 int, float, long, double, decimal [0,360] decimal [0,360] Angle (°)
5.004 int, float, long, double, decimal [0,255] int [0,255] Percentage [0,255] (%)
5.010 int, float, long, double, decimal [0,255] int [0,255] Counter Pulses
6.001 int, float, long, double, decimal [-128,127] int [-128,127] Percentage (%)
6.010 int, float, long, double, decimal [-128,127] int [-128,127] Counter Pulses
9.001 int, float, long, double, decimal [-273,670760] decimal [-273,670760] Temperature in Celsius (°C)

Also working but no implemented as datapoints (see below for better explanation):

  • bit (lights, buttons)
  • byte (dimmers, temperature difference, RGB)

Examples

Connecting using Routing (turn off and on a light)

static void Main(string[] args)
{
  var connection = new KnxConnectionRouting();
  connection.Connect();
  connection.KnxEventDelegate += Event;
  connection.Action("5/0/2", false);
  Thread.Sleep(5000);
  connection.Action("5/0/2", true);
  Thread.Sleep(5000);
}
static void Event(string address, string state)
{
  Console.WriteLine("New Event: device " + address + " has status " + state);
}

Working with datapoints

Sending an action

connection.Action("1/1/16", connection.ToDataPoint("9.001", 24.0f));
connection.Action("1/1/17", connection.ToDataPoint("5.001", 50));

Converting state from event

static void Event(string address, string state)
{
  if (address == "1/1/16")
  {
    decimal temp = (decimal)connection.FromDataPoint("9.001", state);
    Console.WriteLine("New Event: device " + address + " has status " + temp);
    return;
  }
  if (address == "1/1/17")
  {
    int perc = (int)connection.FromDataPoint("5.001", state);
    Console.WriteLine("New Event: device " + address + " has status " + perc);
    return;
  }
}

Requesting status

Sending an action

connection.KnxStatusDelegate += Status;
connection.RequestStatus("1/1/16");
connection.RequestStatus("1/1/17");

Converting state from status event

static void Status(string address, string state)
{
  if (address == "1/1/16")
  {
    decimal temp = (decimal)connection.FromDataPoint("9.001", state);
    Console.WriteLine("New Event: device " + address + " has status " + temp);
    return;
  }
  if (address == "1/1/17")
  {
    int perc = (int)connection.FromDataPoint("5.001", state);
    Console.WriteLine("New Event: device " + address + " has status " + perc);
    return;
  }
}

Sending actions without using datapoints

connection.Action("1/1/19", true);
connection.Action("1/1/20", false);
connection.Action("1/1/21", 60);
connection.Action("1/1/22", 0x4E);

Connecting using Tunneling

The only difference is how the connection object is created

connection = new KNXConnectionTunneling(remoteIP, remotePort, localIP, localPort);

Notes

If connecting in routing mode:

  • make sure the system firewall allows incoming connections to the routing port (if not specified when connecting, default is 3671)

If connecting in tunneling mode:

  • make sure the system firewall allows incoming connections to the specified localPort

knx.net's People

Contributors

abelsilva avatar cumpsd avatar gioviq avatar tiagoad avatar

Watchers

 avatar  avatar

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.