snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

Ventilation percentage based #77

Closed hyperbart closed 7 years ago

hyperbart commented 7 years ago

Ok, not really an issue, but more of a question/technical view. I hope it's okay to ask it here

Recently the characteristics aspect got introduced, so you can create a "thing" in Homebridge and give it any characteristic you like. That made me wonder and I started digging a little bit in the classifications of devices.

I want to control the ventilation system in my house. It's a fully balanced system which works with an RF remote, but it also accepts a 0-10V input. Hence why I bought an MDT 0-10V actor to control it. However I also want to be able to control it from my Home app.

Can i add an icon/item with the fan icon to represent "ventilation" but instead of it controlling a smart fan controlling my ventilation? The issue here lies in the fact (at least that what I think) that the "fan" class/item has a 0/1/2 value if I understood correctly while my ventilation (being the 0-10V output) will be controlled by a percentage value.

TL;DR: Is it possible to create a "fan" icon to represent my ventilation and make it send out a percentage value instead of 0/1/2?

snowdd1 commented 7 years ago

Why?

There is a Fan service that supports RotationSpeed, which is a percentage. This characteristic is also supported by the Fanv2 service which I think is some kind of update.

In both cases you might need an On or (v2) Active characteristic to switch it on or off, and an additional characteristic for the percent speed.

hyperbart commented 7 years ago

What do you mean "why"? 😄

Why I want to connect my ventilation unit to KNX? Because I want to automate the intensity of the ventilation based on home-usage (eg. showering, cooking, toilet, sleeping etc). Why I want to connect my ventilation to HomeKit? Because I have my whole KNX setup in Homebridge/HomeKit and I want to be able to manually override ventilation automation with it. Why I want the fan icon: useability and if it's something else causing a slight nervous twitch in my eyes every time I would open HomeKit and see "Ventilation" with a lamp icon or something like that.

Problem is that the ventilation unit is permanently on. So in theory you shouldn't be able to turn it off, the unit itself does not support an OFF command unless you unplug it or switch it off by cutting the power from the line-feed. However I could solve this if the class supports different addresses like one for turning ON/OFF and one for intensity%.

How would this look like in reality?

Let's say I have an address 1/0/10 for intensity%, 1/1/10 for ON/OFF and 1/1/11 for ON/OFF feedback. How would the snippet of config look then to give me a fan icon that controls my ventilation with a percentage slider?

snowdd1 commented 7 years ago

Sorry, have to admit that my reply "why" was sufficiently imprecise!
I was wondering why you didn't just use the service that was already in HomeKit, but I think I understood now that you asked how to do that.

Well, it's comparable to a lamp with a dimmer:

         {
            "DeviceName": "Ventilation Device",
            "Services": [
                {
                    "ServiceType": "Fan",
                    "ServiceName": "Ventilation",
                    "Characteristics": [
                        {
                            "Type": "On",
                            "Set": [
                                "1/1/10"
                            ],
                            "Listen": [
                                "1/1/11"
                            ]
                        },
                        {
                            "Type": "RotationSpeed",
                            "Set": [
                                "1/0/10"
                            ],
                            "Listen": [
                                "1/0/10"
                            ]
                        }
                    ]
                }
            ]
        }

What I do not know (never tested) is which HomeKit app really supports that with icon and all.

You might want to test this thoroughly, because of the Apple glitch we discovered with the dimmers might be relevant here as well: #47 Brightness is set when switching on a lightbulb
If that is the case you might notice that On is triggered when changing RotationSpeed and vice versa.

hyperbart commented 7 years ago

Sorry, have to admit that my reply "why" was sufficiently imprecise! I was wondering why you didn't just use the service that was already in HomeKit, but I think I understood now that you asked how to do that.

Haha, correct, I was indeed wondering IF it is possible and if so, how :)

You might want to test this thoroughly, because of the Apple glitch we discovered with the dimmers might be relevant here as well: #47 If that is the case you might notice that On is triggered when changing RotationSpeed and vice versa.

Ah yes, that wonderful bug, has been annoying me for a while now... Will test and report back.

What I do not know (never tested) is which HomeKit app really supports that with icon and all.

Elgato EVE supports the full filosophy of HomeKit, while Apple's Home doesn't. EVE can display the various statistics of a device.

hyperbart commented 7 years ago

FYI, somebody already slapped something together to show the airco of a Tesla as a fan icon so I'm pretty hopeful about the fan icon controlling a pct-value:

whatsapp image 2016-10-25 at 20 07 07

hyperbart commented 7 years ago

Okay, small update here.

I added the snippet to my Homebridge and was greeted with an animated fan which I could control with the percentage.

A quick glance in ETS showed that when I selected a percentage I saw the corresponding value, however what I didn't take into account was the DPT.

image

Nice one btw, it always sends an ON value followed by the percentage (as you can see in ETS, 30 and 34%)

Apparently it sends the % as a DPT 9 and the analog input expects a percentage 1Byte. Any way how I could fix this within ETS?

snowdd1 commented 7 years ago

That's weird, because % in HomeKit definition gets translated to DPT5.001. Are you sure you have configured the group addresses in ETS correctly? Because DPTs cannot be guessed correctly from the telegram itself in all cases - but usually a DPT5.001 is shown as DPT5, as it has the same length (1 Byte) and differs only in interpretation (DPT5 255 = DPT5.001 100%).
You could try to put "DPT": "DPT5.001" next to the "Type":"RotationSpeed" to force it to DPT5.001; you might also look into homebridge log (or system log if you run it as a system service) to see what homebridge-knx writes into that when changing a value.

hyperbart commented 7 years ago

That's weird, because % in HomeKit definition gets translated to DPT5.001.

Is it really? Because the type in HAP-NodeJS shows this:

format: Characteristic.Formats.FLOAT, unit: Characteristic.Units.PERCENTAGE, maxValue: 100, minValue: 0,

I will test again tonight with an empty GA.

snowdd1 commented 7 years ago

Ahh, da*n it, they now have Brightness

    format: Characteristic.Formats.INT,
    unit: Characteristic.Units.PERCENTAGE,
    maxValue: 100,
    minValue: 0,
    minStep: 1,

and RotationSpeed

    format: Characteristic.Formats.FLOAT,
    unit: Characteristic.Units.PERCENTAGE,
    maxValue: 100,
    minValue: 0,
    minStep: 1,

So you definitely have to force it to DPT5.001 for KNX, as homebridge-knx will assume that's a DPT9 right after reading the characteristic is a Characteristic.Formats.FLOAT in homekit, and will not check the Characteristic.Units.PERCENTAGE if it might be a percentage type nevertheless.

And with that I found a bug in https://github.com/snowdd1/homebridge-knx/blob/master/lib/characteristic-knx.js#L234 where it says PERCENTAGE assumed to be a Formats not a Units member, which it isn't. I'll make a new Issue for that bug, because it doesn't have to do with ventilation natively, just coincidently.

hyperbart commented 7 years ago

Jup, DPT 5.001 forces a percentage, wonderful! MDT 0-10V unit now gives corresponding voltage 👍 .