tschamm / boschshc-hass

Home Assistant component for accessing Bosch Smart Home Controller using boschshcpy python library.
Other
172 stars 27 forks source link

Support for Bosch Window / Door Contact II VibrationSensor #78

Closed obstbauer88 closed 12 months ago

obstbauer88 commented 1 year ago

Hi,

I just got the Bosch Window / Door Contact II. I was able to integrate them into HA. But I was not able to add the vibration sensors in HA. Could you please add the support for this sensor? Or is it already there and I have overseen it?

Thanks in advance!

Br

tschamm commented 1 year ago

Hi, support not yet given, as I need a dump of the Postman device response as well as the individual service response. For a good example, see https://github.com/tschamm/boschshcpy/pull/20

tschamm commented 1 year ago

Hi @obstbauer88 please make a rawscan and dump the results of the Window Contact II here. See also https://github.com/tschamm/boschshcpy#rawscans

Mr-Mistoffelees commented 1 year ago

I own some Windows / Door Contact II sensors. Happy to help. Performed the rawscan(s) as described by yourself here.

Changed the last digits of the bridge's IP and the last five digits from the serial to nnnnn. If there is any reason you need them, please let me know.

boschshc_rawscan -ip 192.168.nnn.nnn -cert client-cert.pem -key client-key.pem device hdm:ZigBee:18fc2600000nnnnn

{
    "@type": "device",
    "rootDeviceId": "64-da-a0-12-nn-nn",
    "id": "hdm:ZigBee:18fc2600000nnnnn",
    "deviceServiceIds": [
        "CommunicationQuality",
        "ShutterContact",
        "BatteryLevel",
        "Bypass",
        "VibrationSensor"
    ],

    "manufacturer": "BOSCH",
    "roomId": "hz_2",
    "deviceModel": "SWD2_PLUS",
    "serial": "18FC2600000nnnnn",
    "profile": "REGULAR_WINDOW",
    "iconId": "icon_tfk_winged_window",
    "name": "Fenster Sp\u00fcle",
    "status": "AVAILABLE",
    "childDeviceIds": [],
    "supportedProfiles": []
}

boschshc_rawscan -ip 192.168.nnn.nnn -cert client-cert.pem -key client-key.pem device_services hdm:ZigBee:18fc2600000nnnnn

[
    {
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "BatteryLevel",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/BatteryLevel"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ShutterContact",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "shutterContactState",
            "value": "CLOSED"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/ShutterContact"
    },
    {
        "@type": "DeviceServiceData",
        "id": "Bypass",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "bypassState",
            "state": "BYPASS_INACTIVE",
            "configuration": {
                "enabled": true,
                "timeout": 5,
                "infinite": false
            }
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/Bypass"
    },
    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }
]

If you need anything else: You are welcome!

Thanks for your amazing work btw. :)

tschamm commented 1 year ago

That’s great, thank you. Can you also give the enumerator values for VibrationSensor (NO_VIBRATION, ?) as well as Bypass (BYPASS_INACTIVE, BYPASS_ACTIVE I guess). You need to do the raw scan when these services are active, hence you press the Bypass and do another rawscan.

Mr-Mistoffelees commented 1 year ago

Thanks for your response on a short notice. Here is the bypass example while alarm is armed. Your assumption regarding BYPASS_ACTIVE was correct:

$ boschshc_rawscan -ip 192.168.nnn.nnn -cert client-cert.pem -key client-key.pem device_services hdm:ZigBee:18fc2600000nnnnn

[
    {
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "BatteryLevel",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/BatteryLevel"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ShutterContact",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "shutterContactState",
            "value": "CLOSED"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/ShutterContact"
    },
    {
        "@type": "DeviceServiceData",
        "id": "Bypass",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "bypassState",
            "state": "BYPASS_ACTIVE",
            "configuration": {
                "enabled": true,
                "timeout": 5,
                "infinite": false
            }
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/Bypass"
    },
    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }
]

Vibration while alarm is NOT armed:

$ boschshc_rawscan -ip 192.168.nnn.nnn -cert client-cert.pem -key client-key.pem device_services hdm:ZigBee:18fc2600000nnnnn

[
    {
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "BatteryLevel",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/BatteryLevel"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ShutterContact",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "shutterContactState",
            "value": "CLOSED"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/ShutterContact"
    },
    {
        "@type": "DeviceServiceData",
        "id": "Bypass",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "bypassState",
            "state": "BYPASS_INACTIVE",
            "configuration": {
                "enabled": true,
                "timeout": 5,
                "infinite": false
            }
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/Bypass"
    },
    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "VIBRATION_DETECTED",
            "sensitivity": "HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }
]

Vibration while alarm is armed:

$ boschshc_rawscan -ip 192.168.nnn.nnn -cert client-cert.pem -key client-key.pem device_services hdm:ZigBee:18fc2600000nnnnn
[
    {
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "BatteryLevel",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/BatteryLevel"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ShutterContact",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "shutterContactState",
            "value": "CLOSED"
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/ShutterContact"
    },
    {
        "@type": "DeviceServiceData",
        "id": "Bypass",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "bypassState",
            "state": "BYPASS_INACTIVE",
            "configuration": {
                "enabled": true,
                "timeout": 5,
                "infinite": false
            }
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/Bypass"
    },
    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "VIBRATION_DETECTED",
            "sensitivity": "HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }
]

If you need anything let me know. Also happy to help testing.

tschamm commented 1 year ago

Sensitivity states are HIGH, MEDIUM and LOW?

Mr-Mistoffelees commented 1 year ago

VERY_LOW

    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "VERY_LOW",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }

LOW

    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "LOW",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }

MEDIUM


    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "MEDIUM",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }

HIGH

    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }

VERY_HIGH

    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "VERY_HIGH",
            "enabled": true
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }

Tried a bit around what happens, when this feature is deactivated in the app. sensitivity stays on its last state, while enabled turns to false:

    {
        "@type": "DeviceServiceData",
        "id": "VibrationSensor",
        "deviceId": "hdm:ZigBee:18fc2600000nnnnn",
        "state": {
            "@type": "vibrationSensorState",
            "value": "NO_VIBRATION",
            "sensitivity": "VERY_HIGH",
            "enabled": false
        },
        "path": "/devices/hdm:ZigBee:18fc2600000nnnnn/services/VibrationSensor"
    }
tschamm commented 1 year ago

Thanks

tschamm commented 1 year ago

Can you test the latest version 0.4.64? Bypass was already available in previous versions, but only as a config value (only shown on the device page). Vibration sensor is added, you should also be able to enable/disable vibration on the device page. I have not implemented change of the vibration sensitivity, as well did I not implement enable/disable of the bypass button. As I cannot test the functionality, I would be glad if you could report back if there are things missing. Thanks!

tschamm commented 1 year ago

Maybe the bypass still lacks reporting the correct state in HA, see also #89

tschamm commented 1 year ago

Found the potential error for bypass, too bad if testing is not possible without owning the devices... Version 0.4.65 should work.

Mr-Mistoffelees commented 1 year ago

Not a problem. Happy to help (even if I have to continue tomorrow. By the way: Wow, this is the fastes answer to a feature request I've ever seen. :)

Test with the initial 0.4.64.

Looks good, just an idea: Vibration might fit under sensors (if this is planned anyway, please ignore).

grafik

Vibration is was also detected correctly:

grafik

Regarding bypass: Should this be configurable in the upper right hand corner under "Steuerelemente"? grafik

Will continue tomorrow.

Mr-Mistoffelees commented 1 year ago

Have to report that bypass doesn't seem to work. Also no change when activiating bypass while alarm is triggered.

Upade: Initially posted the wrong picture grafik

tschamm commented 1 year ago

I just ordered a sensor to test this button functions, hopefully that issue can be closed soon.

Mr-Mistoffelees commented 1 year ago

Wow, crazy. Looking forward for this. :)

For those who concern: Thanks to @tschamm's great work, I'm able to get the status of the Bosch bridge, regarding the intrusion system. So when I leave my home, I arm the Bosch system by pressing the button (which is configured in Bosch App). When the alarm is set to home_away some seconds later, this is detected by HA and triggers an automation for presence detection. If an alarm is triggered, another automation in HA is triggered. So everything I need is fully working.

Of course, the solution is not 100 % idiomatic, but I would consider it as a peaceful and reliable co-existence between both systems. :)

tschamm commented 12 months ago

My sensor has arrived, and I found a bug which prevented to binary sensor platform to load correctly. Bypass is now available. However, pressing the button short/long is not published via the Bosch API, so that event cannot be captured. Fixed in commit https://github.com/tschamm/boschshc-hass/commit/e7f98da1b4c797bea048c26dbd4029d31b0bc181.