ActiveByte / homebridge-loxone-connect

Websocket based homebridge plugin for controlling Loxone.
MIT License
23 stars 8 forks source link

Support for digital sensors "InfoOnlyDigital" #14

Open dcn220179 opened 2 years ago

dcn220179 commented 2 years ago

It would be great if not only the type "InfoOnlyAnalog" is supported for sensors. At least my contact, doorbell and motion sensors are from type "InfoOnlyDigital". See: "Platform - The widget 'Kontakt Garagentor' of type InfoOnlyDigital is an item not handled." Is there a reason that you only check for analog sensors or is it possible to add some digital sensors?

marcelschreiner commented 5 months ago

Hello @dcn220179

In my opinion this is only an artificial limitation... I did some tests on my end and it seems like it should be possible to also accept InfoOnlyDigital values too.

@ActiveByte I'd appreciate your thoughts on this.

In ItemFactory.js I changed the code from this

    if (item.type == "InfoOnlyAnalog") {
        if (item.name.includes(alias('Contact'))) {
            item.type = "ContactSensor"; 
        } else if (item.name.includes(alias('Doorbell'))) {
            item.type = "Doorbell";
        } else if (item.name.includes(alias('Motion'))) {
            item.type = "MotionSensor";
        } else if (item.name.includes(alias('Brightness'))) {
            item.type = "LightSensor";
        } else if (item.name.includes(alias('Trigger'))) {
            item.type = "Trigger";
        }else if (item.name.includes(alias('Temperature'))) {
            item.type = "TemperatureSensor";
        }else if (item.name.includes(alias('Humidity'))) {
            item.type = "HumiditySensor";
        }else if (item.name.includes(alias('Smoke'))) {
            item.type = "SmokeSensor";
        }else if (item.name.includes(alias('Leak'))) {
            item.type = "LeakSensor";
        }
    }

to this:

    if (item.type == "InfoOnlyAnalog") {
        if (item.name.includes(alias('Brightness'))) {
            item.type = "LightSensor";
        } else if (item.name.includes(alias('Temperature'))) {
            item.type = "TemperatureSensor";
        } else if (item.name.includes(alias('Humidity'))) {
            item.type = "HumiditySensor";
        }
    }
    if ((item.type == "InfoOnlyAnalog")||(item.type == "InfoOnlyDigital")) {
        if (item.name.includes(alias('Contact'))) {
            item.type = "ContactSensor"; 
        } else if (item.name.includes(alias('Doorbell'))) {
            item.type = "Doorbell";
        } else if (item.name.includes(alias('Trigger'))) {
            item.type = "Trigger";
        } else if (item.name.includes(alias('Motion'))) {
            item.type = "MotionSensor";
        } else if (item.name.includes(alias('Smoke'))) {
            item.type = "SmokeSensor";
        } else if (item.name.includes(alias('Leak'))) {
            item.type = "LeakSensor";
        }
    }