JoDehli / PyLoxone

Python Loxone binding
Apache License 2.0
183 stars 41 forks source link

Wrong on/off reporting for door/window contacts #152

Closed hatl closed 1 year ago

hatl commented 1 year ago

Which Model do you use from loxone? Miniserver? Gen1 or Gen2? Gen1

Which software version does your loxone use? latest

How did you install HomeAssistant? Over Hassio oder manual install? Hassio

Which Version do you use of HomeAssistant? latest

Describe the bug The door/window contact state is reported wrongly. PyLoxone reports "on" for closed. But Home Assistant interprets "on" as "open"

opening: on means open, off means closed

see: https://www.home-assistant.io/integrations/binary_sensor/

JoDehli commented 1 year ago

How did you configure the window sensor? Is it a custom sensor?

hatl commented 1 year ago

It's a Loxone Door & Window Contact Air White No manual configuration Automatically configured by Loxone Config Automatically detected by PyLoxone

image

According to the Loxone documentation: closed = 1, open = 0

image

Which unfortunately is the opposite logic of what's expected by Home Assistant

JoDehli commented 1 year ago

Have you access to your configuration.json?

hatl commented 1 year ago

the Loxone config? "name":"Fenster Kontakt","type":"InfoOnlyDigital"

which information are you interested in?

JoDehli commented 1 year ago

Ok if it is a digital info we can not change the behaviour.

Is the digital info alone or a subsection of a other device.

JoDehli commented 1 year ago

@hatl So now I am back from vacation and I can reply. Can you sent me the Loxone Config part oft the whole window contact sensor. Is it grouped together in one control? Do you know what I mean?

hatl commented 1 year ago

i've copied the relevant sections. it's not grouped in a control. in the description you also see the orign of the mismach: "off": "Offen" (open) vs on = open in home assistant


"cats": {
    "__CATEGORY_ID__": {
        "uuid": "__CATEGORY_ID__",
        "name": "Überwachung",
        "image": "IconsFilled/cc-camera.svg",
        "defaultRating": 0,
        "isFavorite": false,
        "type": "undefined",
        "color": "#69C350"
    },

    "controls": {
        "__CONTROL_ID__": {
            "name": "Fenster Kontakt",
            "type": "InfoOnlyDigital",
            "uuidAction": "__CONTROL_ID__",
            "room": "__ROOM_ID__",
            "cat": "__CATEGORY_ID__",
            "defaultRating": 0,
            "isFavorite": false,
            "isSecured": false,
            "defaultIcon": null,
            "restrictions": 0,
            "details": {
                "jLockable": false,
                "text": {
                    "off": "Offen",
                    "on": "Geschlossen"
                },
                "color": {
                    "off": "#E73246",
                    "on": "#69C350"
                }
            },
            "states": {
                "active": "__CONTROL_ID__"
            }
        },```
JoDehli commented 1 year ago

@hatl Ok I think you have 2 options. One is to invert the logic on the loxone itself for the window contact sensor or create a virtual senor with a inverted output of all window sensor and only observe this ones in home assistant.

Or you create a template sensors of all of your window sensor in homeassistant and use this ones. This has the advantage that you can use the original sensors in Loxone and the template sensor is home assistant.

Other than that I can not switch the logic in pyloxone as it makes other sensors behave wrong.

hatl commented 1 year ago

it's unfortunate, that it's not possible to identify the sensor type thanks for your support and suggestions

for anyone else coping with this issue: i chose creating the template sensors in the following way

binary_sensor: 
  - platform: template
    sensors:
      NEW_ENTITY_NAME:
        value_template: >-
          {{ is_state('binary_sensor.LOXONE_ENTITY', 'off') }}
        device_class: window
        friendly_name: Window Sensor
zamojski commented 2 months ago

Is there any chance to extend InfoOnlyDigital with inverted property on the Home Assistant side?