Giter VIP home page Giter VIP logo

homematic-xml-rpc's Introduction

Homematic-XML-RPC API for desktop and android (server and client)

Some helpfull links:

How to use:

implements HomematicListener.Listener

/*
if you use andoid add in Manifest

<uses-permission android:name="android.permission.INTERNET"/>

<application
...
android:usesCleartextTraffic="true"
 */
 
public Main(){
    new HomematicServer(12345).start();

    new HomematicListener().setListener(this);

    sendinit();
}

/*
Send init to CCU

This command started a client on the CCU who sent the new values​from the actuators (e.g. switching status).
The command must be send to the port for Homematic and Homematic IP deposits.
*/
private void sendinit(){
    String ipccu = "192.168.0.11";         //IP CCu
    String yourIP = "http://192.168.0.10:12345/";        //your own IP and port

    //Send int for Homematic IP port 2010
    new HomematicClient().init(ipccu, "2010", yourIP, "hmIPClient");

    //Send int for Homematic port 2001
    new HomematicClient().init(ipccu, "2001", yourIP, "hmClient");
}

/*
After success init, the CCU send all devices
 */
@Override
public void onNewDevice(Object[] objects) {
    for (Object o: objects){
        String type = "";
        String address = "";

        String[] strings = o.toString().split(",");

        for(String s: strings){
            if (s.contains("PARENT=")){
                address = s.substring(s.indexOf('=') + 1);
            }

            if (s.contains("PARENT_TYPE=")){
                type = s.substring(s.indexOf('=') + 1);
            }
        }

        System.out.println("The device " + address + " is a " + type);
    }
}

/*
If device change value the CCU send the new value
 */
@Override
public void onValueChange(String device, String valueKey, Object value) {
    System.out.println(device + " has a new " + valueKey + " " + value);
}

/*
set new value
*/
private void setValue(){
    String ip = "192.168.0.11";         //IP CCu
    String port = "2010";               //port 2001 for Homematic / port 2010 for Homematic IP

    String device = "000AB16A0:4";      //actuator
    String valueKey = "STATE";
    boolean value = true;

    String user = "user";
    String pwd = "12345678";

    //without authentication
    new HomematicClient().setValue(ip, port, device, valueKey, value);

    //with authentication
    new HomematicClient().setValue(ip, port, device, valueKey, value, user, pwd);
}

/*
get value from device
*/
private Object getValue() {
    String ip = "192.168.0.11";         //IP CCu
    String port = "2010";               //port 2001 for Homematic / port 2010 for Homematic IP

    String device = "000AB16A0:4";      //actuator
    String valueKey = "STATE";

    String user = "user";
    String pwd = "12345678";

    //without authentication
    //new HomematicClient().getValue(ip, port, device, valueKey);

    //with authentication
    return new HomematicClient().getValue(ip, port, device, valueKey, user, pwd);
}

homematic-xml-rpc's People

Contributors

bug405 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.