Coder Social home page Coder Social logo

Comments (2)

steilerDev avatar steilerDev commented on August 19, 2024

HI @Tazintosh,

what you are trying is not something that can be achieved in this plugin. I just introduced a communication layer, showing items from openHAB in HomeKit, but since you have four different items in openHAB those are shown as 4 items in HomeKit as well.

Preface: I hope I understand your setup correctly and I did not directly test all of those rules (there might be syntax errors in there), since I don't have access to your environment, just trying to give you an understanding, so you can go and find the best way for you. Since this is at it's core an openHAB question, feel free to contact the nice folks over at the openHAB community

I would suggest creating a proxy item in one of your item files without specifying any binding (The other three items should already be defined with your respective binding, not sure just guessing here):
led.items

Color myLEDProxyItem
Switch myLEDPower {<<yourbinding>>}
Color myLEDColor {<<yourbinding>>}
Dimmer myLEDBrightness {<<yourbinding>>}

(The myLEDProxyItem would be the one item you would add to your home bridge configuration)

Then you would create a rule, that monitors incoming commands to your proxy item and push them to your other items, while changing your proxy item if your other items are changed.

led.rules

import java.lang.Integer
import java.lang.NumberFormatException

rule 'incoming proxy request'
when
    Item myLEDProxyItem received command
then
    if (receivedCommand == "ON" || receivedCommand == "OFF") {
        myLEDPower.sendCommand(receivedCommand);
    } else {
        try {
            val int num = Integer.parseInt(receivedCommand)
            myLEDBrightness.sendCommand(receivedCommand);
            // not sure if your accessory is 'smart enough' to also trigger the switch on, when a brightness is set, if not you would need something like this:
           if(receivedCommand > 0) {
                myLEDPower.sendCommand("ON");
            } else {
                myLEDPower.sendCommand("OFF");
            }
        } catch (NumberFormatException e) {
            // String is not a number
            //now this should be a color couple, as mentioned above, if your items are not 'smart enough', you would need to parse the 'receivedCommand' and perform brightness and power settings as well, I am a little bit lazy at the moment, therefore I would suggest you to give it a try, feel free to post if you can't find a solution :P
            myLEDColor.sendCommand(receivedCommand);
        }
end

rule "brightness led changed"
when
    myLEDBrightness changed
then
    myLEDProxyItem.postUpdate(myLEDBrightness.state);
end

rule "power led changed"
when
    myLEDPower changed
then
    myLEDProxyItem.postUpdate(myLEDPower.state);
end

rule "color led changed"
when
    myLEDColor changed
then
    myLEDProxyItem.postUpdate(myLEDColor.state);
end

As said earlier, I did this quickly while on the train without really checking it, but it should give you an idea how to create and keep proxy items in sync. I hope that helped.

from homebridge-openhab2-complete.

Tazintosh avatar Tazintosh commented on August 19, 2024

Hi @steilerDev,
I'm happy you did not put much time into this but still, I'm sure it will help some other people that were in my case. The proxy concept is cool, I was clearly missing this.

Anyway, since more than 2 weeks, my configuration has much evolved.
In fact, I've dropped Openhab for now. The learning curve was way to long, for unsatisfying results (sadly) an big needs (need to learn new language to write rules etc.)
I've installed Node-RED and the overall experience is immensely better (not speaking writing rules were functions are just javascript). The HomeKit palette "node-red-contrib-homekit-bridged" is a real pleasure, producing a "native" HomeKit device with all expectations.

Thanks @steilerDev

from homebridge-openhab2-complete.

Related Issues (20)

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.