tschamm / boschshc-hass

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

Integration SmartRelais #101

Closed COLT9001 closed 6 months ago

COLT9001 commented 1 year ago

The integration of the new Smart Relay is currently not yet available. It would be great if this integration would be possible.

https://www.bosch-smarthome.com/de/de/produkte/geraete/smartes-relais/

tschamm commented 1 year ago

Can you provide the raw-scan info on this device? Then I can add the missing functionality.

COLT9001 commented 1 year ago

Yes of course, no problem at all. I could do that right now! But: Where and how exactly must this be done. I have found no info via classic search engines, how I can do this for HA.

A short info or tutorial would be great.

COLT9001 commented 1 year ago

Ok i made it. Whereby Python is not really something for "Ottonormalverbraucher" ;-)

{
    "@type": "device",
    "rootDeviceId": "xx-xx-xx-xx-xx-xx",
    "id": "hdm:ZigBee:705464fffexxxxxx",
    "deviceServiceIds": [
        "CommunicationQuality",
        "PowerSwitch",
        "ChildProtection",
        "PowerSwitchProgram",
        "ElectricalFaults",
        "SwitchConfiguration"
    ],
    "manufacturer": "BOSCH",
    "roomId": "hz_1",
    "deviceModel": "MICROMODULE_RELAY",
    "serial": "705464FFFExxxxxx",
    "profile": "LIGHT",
    "iconId": "ip_lamp_bulb_1",
    "name": "Flurlicht",
    "status": "AVAILABLE",
    "childDeviceIds": [],
    "supportedProfiles": []
}
tschamm commented 1 year ago

@COLT9001 Thank you for the rawscan. I'm implementing the functionality right now. AFAIK, the relay can be used either as "toggle" or as "push" button. In the example above you configured the relay as Light, which would expect "toggle" (I guess). Maybe you can also provide a rawscan of the relay configured in "push" mode, so that we know the profile and the device services.

tschamm commented 1 year ago

Support for smart relay is available with 3a1e888

tschamm commented 1 year ago

Can you test and close the issue, if it is working as expected?

hkohls commented 1 year ago

I had the same issue, so I am happy you did the change. I have testet it and it works fine so far!

Now for the missing part I have some infos for you:

I am using the configuration "ImpulseSwitch", here is an extract from the rawscan. If you need more, just let me know!

{

"@type": "device", 
"rootDeviceId": "64-da-a0-40-5d-7b", 
"id": "hdm:ZigBee:287681fffe705763", 
"deviceServiceIds": [ 
    "CommunicationQuality", 
    "ImpulseSwitch", 
    "ChildProtection", 
    "ElectricalFaults" 
], 
"manufacturer": "BOSCH", 
"roomId": "hz_1", 
"deviceModel": "MICROMODULE_RELAY", 
"serial": "287681FFFE705763", 
"profile": "GENERIC", 
"iconId": "ip_garage", 
"name": "Garagentor", 
"status": "AVAILABLE", 
"childDeviceIds": [], 
"supportedProfiles": [] 

},

[ { "@type": "DeviceServiceData", "id": "ImpulseSwitch", "deviceId": "hdm:ZigBee:287681fffe705763", "state": { "@type": "ImpulseSwitchState", "impulseState": false, "impulseLength": 10, "instantOfLastImpulse": "2023-08-12T17:04:08.569170Z" }, "path": "/devices/hdm:ZigBee:287681fffe705763/services/ImpulseSwitch" }, { "@type": "DeviceServiceData", "id": "CommunicationQuality", "deviceId": "hdm:ZigBee:287681fffe705763", "state": { "@type": "communicationQualityState", "quality": "GOOD" }, "path": "/devices/hdm:ZigBee:287681fffe705763/services/CommunicationQuality" }, { "@type": "DeviceServiceData", "id": "ChildProtection", "deviceId": "hdm:ZigBee:287681fffe705763", "state": { "@type": "ChildProtectionState", "childLockActive": true }, "path": "/devices/hdm:ZigBee:287681fffe705763/services/ChildProtection" }, { "@type": "DeviceServiceData", "id": "ElectricalFaults", "deviceId": "hdm:ZigBee:287681fffe705763", "path": "/devices/hdm:ZigBee:287681fffe705763/services/ElectricalFaults" } ]

COLT9001 commented 1 year ago

The function with the light works perfectly

tschamm commented 1 year ago

Need to add the impulse switch.

DFS-90 commented 11 months ago

@tschamm : I've also just installed the micromodule relay as an impulse switch. Do you need more / other scans?

Snakesnipe commented 11 months ago

It would be great if you could also access the power and energy?

sebastianharder commented 11 months ago

@Snakesnipe, the relay does not measure power consumption because it is potential free.

COLT9001 commented 10 months ago

Hi, after Update SmartRelais is still not working. It works perfectly in the Bosch app. But in HA not.... >> This entity is no longer being provided by the bosch_shc integration. If the entity is no longer in use, delete it in settings.

tschamm commented 10 months ago

I'm following up pn this. Same issue is reported in #113 Can you check the log files, if an error is reported?

tschamm commented 10 months ago

@COLT9001 SmartRelais should be available again. For the impulse switch, I'm still thinking of how that should be integrated in HA best

kwiat commented 10 months ago

Hi! Thanks for the wonderful integration! Using the relay as an impulse replacing the remote of my garage door. It works as a stateless (impulse) button in the official Bosch app. With the Bosch Alexa skill it’s (only) useable with a scene that triggers the device. Maybe a scene button in home assistant (that has the device and “default action”) that activates on button press could work as well here?

tschamm commented 10 months ago

Yes, HA is quite fuzzy on this. Implementing that as an event would be most convenient, but this would prevent you from calling that impulse switch via HA. In the Bosch app, can you only trigger the switch, or do you have also some kind of a state?

kwiat commented 10 months ago

In the official app it's a big white stateless button you can press, not a switch or anything. Hope this helps!

kwiat commented 9 months ago

IMG_5186 Here is a screenshot from the iOS app. Would be awesome to see that supported!

tschamm commented 9 months ago

Thanks. So what you would expect is a button in HA, which you can press instead of the button on the wall/the button in the official App. Correct? A button entity would be what I initially planned to use, but HA is quite clear this should not be used. But maybe it is still the best way to go.

DFS-90 commented 9 months ago

I solved this problem like this (be warned - this is a little bit complicated):

alias: Relais ansteuern
sequence:
  - service: python_script.exec
    data:
      source: |
        import requests
        url = 'https://<YOUR_CONTROLLER_IP>:8444/smarthome/devices/hdm:ZigBee:XXXXXXXXXXX/services/ImpulseSwitch/state'
        json={"@type": "ImpulseSwitchState","impulseState": "true"}
        cert_file_path = "/config/bosch_shc/bosch_shc-cert_<MAC>.pem"
        key_file_path = "/config/bosch_shc/bosch_shc-key_<MAC>.pem"
        cert = (cert_file_path, key_file_path)
        r = requests.put(url,json=json,cert=cert,verify=False)

This works fine for me. Maybe @tschamm (thanks for your awesome work!) has an idea how to automate this?

Best regards, David

tschamm commented 6 months ago

For those using a micromodule_relay: Can you plz check whether 0.4.84 works?

danielpetrovic commented 6 months ago

Sorry, I have removed the Bosch SHC II and just connected the Relay to Z2M which works fine. ZHA also works for people using that.

Salrok commented 6 months ago

@tschamm where do i get 0.4.84?

bsh

tonez18 commented 6 months ago

@Salrok you can install it manually. Just download the latest master version https://github.com/tschamm/boschshc-hass/releases/tag/0.4.85 and upload the files from bosch_shc to custom_components/bosch_shc

@tschamm button appears and it is working as expected. Great work

jph76 commented 6 months ago

I solved this problem like this (be warned - this is a little bit complicated):

* Take your SHC certificate and key file from your HomeAssistant server (located at /config/bosch_shc/ - they are named "bosch_shc-cert_.pem" and "bosch_shc-key_.pem") and copy them to your PC

* Install Postman, add the Bosch SHC Postman collection and setup your controller (see [here](https://github.com/BoschSmartHome/bosch-shc-api-docs/tree/master/postman)) (you will need your cert file, your key file and your controller password)

* Find device ID for your relais

Thanks, @DFS-90, for providing this workaround.

Is the ID obtained this way the same as the ZigBee EUI-64 ID that’s displayed in device settings in the app? I've taken a screenshot from the iPad app:

24-02-03 11-55-04 0776

DFS-90 commented 6 months ago

I solved this problem like this (be warned - this is a little bit complicated):

* Take your SHC certificate and key file from your HomeAssistant server (located at /config/bosch_shc/ - they are named "bosch_shc-cert_.pem" and "bosch_shc-key_.pem") and copy them to your PC

* Install Postman, add the Bosch SHC Postman collection and setup your controller (see [here](https://github.com/BoschSmartHome/bosch-shc-api-docs/tree/master/postman)) (you will need your cert file, your key file and your controller password)

* Find device ID for your relais

Thanks, @DFS-90, for providing this workaround.

Is the ID obtained this way the same as the ZigBee EUI-64 ID that’s displayed in device settings in the app? I've taken a screenshot from the iPad app:

24-02-03 11-55-04 0776

Yes, you're absolutely right - the Zigbee EUI-64 is the same!

In fact, you can assemble it like hdm:ZigBee:<Zigbee EUI-64 from Bosch Smart Home app in small letters and numbers>

DFS-90 commented 6 months ago

@Salrok you can install it manually. Just download the latest master version https://github.com/tschamm/boschshc-hass/releases/tag/0.4.85 and upload the files from bosch_shc to custom_components/bosch_shc

@tschamm button appears and it is working as expected. Great work

I can confirm this. Thanks a lot @tschamm ! 👍

hkohls commented 6 months ago

I reloaded your modules and the intregration works fine with the micromodule_relay. Entity shows up and can be integrated to dashboards. Button can be pressed an triggers the relais. Thanks for completing the work and making this happen!

jph76 commented 6 months ago

@DFS-90 I couldn’t make your example work – imports don’t work with python_script integration (confirmed by documentation), how did you make this black magic work?

Anyway, I wrote a small python program based on your code to be used with AppDaemon add-on:

#!/usr/bin/python3
# -*- coding: utf8 -*-

import hassapi as hass
import requests

SENSOR = "input_boolean.relais_garagentor"

class Garagentor(hass.Hass):
    def initialize(self):
        self.listen_state(self.move, SENSOR, new = "on")

    def move(self, entity, attribute, old, new, cb_args):
        self.turn_off(SENSOR)
        url = "https://<controller IP or hostname>:8444/smarthome/devices/hdm:ZigBee:<lowercase ZigBee EUI-64 from SmartHome app>/services/ImpulseSwitch/state"
        json = {"@type": "ImpulseSwitchState","impulseState": "true"}
        cert_file_path = "/config/bosch_shc-cert.pem"
        key_file_path = "/config/bosch_shc-key.pem"
        cert = (cert_file_path, key_file_path)
        r = requests.put(url, json = json, cert = cert, verify = False)

This script is triggered by an input_boolean relais_garagentor which has to be defined in configuration.yaml.

Certificate and key have to be copied to add-on directory.

Now I can operate my garage gate by talking to my Apple Watch which is kinda useful when arriving by bike in rain. :)

MarkusHaag commented 6 months ago

Hello, I am still new to Home Assistant and HACS, therefore sorry for this silly question. I understand that the relais topic is already working and I could manually update by copying files. Will this update also automatically pushed as update? What is the trigger? Kind regards Markus

tschamm commented 6 months ago

Yes, I just drafted a new release.