RainerStaude / hass-becker-component-plus-pybecker

A native home assistant component to control becker RF shutters with a Becker Centronic USB Stick.
MIT License
44 stars 3 forks source link

Possible to use on HASS installed as VM on Synology DS? #16

Closed mngsps closed 1 year ago

mngsps commented 1 year ago

Dear Rainer and team,

thank you, a lot, for your efforts in providing this! A maybe stupid question: Is it possible to use your code with a Centronic USB stick and HASS installed as VM on a Synology DiskStation?

All the best and thank you for your help in advance Benedikt

RainerStaude commented 1 year ago

It will work if you are able to map USB ports into your VM. The Becker USB port path can be configured - see Readme.

mngsps commented 1 year ago

Hi Rainer,

I bought the recommended Stick and mounted the USB port to my VM. Then In configured my cover as follows:

 - platform: becker
    device: "/dev/serial/by-id/usb-Becker-Antriebe_GmbH_CDC_RS232_v125_Centronic-if00"
    covers:
      dachfenster_bad_og:
        friendly_name: "Dachfenster Bad"
        channel: "1:1" 

When trying to pair in developer tools, it accepts the command but no pairing happens:

service: becker.pair
data:
  channel: 1
  unit: 1

The logs look like this (I tried to pair 1-1 and 1-2 (Roto window opener and another Roto window cover):

2023-02-04 22:00:02.683 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration becker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-02-04 22:00:16.897 INFO (MainThread) [homeassistant.setup] Setting up becker
2023-02-04 22:00:16.898 INFO (MainThread) [homeassistant.setup] Setup of domain becker took 0.0 seconds
2023-02-04 22:00:16.995 INFO (MainThread) [homeassistant.components.cover] Setting up cover.becker
2023-02-04 22:00:17.083 DEBUG (MainThread) [custom_components.becker.cover] device: /dev/serial/by-id/usb-Becker-Antriebe_GmbH_CDC_RS232_v125_Centronic-if00; filename: None
2023-02-04 22:00:17.085 DEBUG (MainThread) [custom_components.becker.rf_device] Use filename: centronic-stick.db
2023-02-04 22:00:17.087 DEBUG (MainThread) [custom_components.becker.pybecker.becker_helper] Try to open connection.
2023-02-04 22:00:17.094 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] BeckerCommunicator thread started.
2023-02-04 22:02:14.401 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00310000001737B0210101008122\x03'
2023-02-04 22:02:14.507 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: RELEASE, argument: 0, packet: b'\x020000000002010B00320000001737B02101010000A2\x03'
2023-02-04 22:02:14.614 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00330000001737B0210101008120\x03'
2023-02-04 22:07:38.931 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00340000001737B021010100811F\x03'
2023-02-04 22:07:39.036 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: RELEASE, argument: 0, packet: b'\x020000000002010B00350000001737B021010100009F\x03'
2023-02-04 22:07:39.138 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00360000001737B021010100811D\x03'
2023-02-04 22:10:02.165 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737C, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00000000001737C0210101008143\x03'
2023-02-04 22:10:02.270 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737C, channel: 1, command: RELEASE, argument: 0, packet: b'\x020000000002010B00010000001737C02101010000C3\x03'
2023-02-04 22:10:02.379 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737C, channel: 1, command: TRAIN, argument: 1, packet: b'\x020000000002010B00020000001737C0210101008141\x03

I'm running HA as VM on a Synology Diskstation 718+. I mapped the USB port as USB 3.0, but there is also an option for USB 2.0 (better?). When I push long on the master remote to enter programming mode I can hear the reaction from the window/cover but nothing happens when I send the pairing from developer tools. The Diskstation with the connected USB stick in one floor below the windows but when I hold the master remots next to the sticks the windows do receive the signal so I guess the distance is fine. Another note: Nothing appears in the logs when pushing remote buttons, even if the remot is next to the stick.

Any idea how to help me getting this to work?

Thank you a lot and all the best Benedikt

RainerStaude commented 1 year ago

Try to map as USB 2.0. device (as the Becker USB Stick is an USB 2.0 Stick). Whatever this changes. Do you see any log messages when you press any key on your remote? There should be a log message whenever you press any key on your remote. Is the USB stick close to your covers? Just to exclude any connection issues. If you encounter connection issues, add an 1-2m USB extension cable between your Synology and the USB stick. This allows to place the stick away from any disturbances. Reboot home assistant.

mngsps commented 1 year ago

Alteady tried to change to USB 2.0 without any notable change. I do not see any logs when pushing buttons on the two remotes (one to open/close one rooftop window, another to control the shutter of another rooftop window, both Roto), even if placing them next to the stick. Interestingly the windows do react when the remotes are next to the stick, even if the distance is indeed a bit far. Is there the option that the remotes have lot more "sending power" compared to the stick? But then the log should work... Will try the USB extension cable and will try to bring the Diskstation with stick closer to the windows for testing. But still wondering for the missing logs when pushing remote buttons and the fact that the remotes can reach the windows from the position of the stick (should suffer from the same disturbances in that place?).

Any further ideas? Will keep you updated...

Thank you for the responsive help!!

mngsps commented 1 year ago

Side question: How to keep formating (paragraphs, indention) when quoting code? It looks fine during editing but loses formating once posted in my case...

RainerStaude commented 1 year ago

See here how to format code I think it is necessary to restart Home Assistent whenever you change something with the USB stick. For example unplug and plug again. Change any VM settings... If your remote is next to the stick and you still do not receive anything, you have an issue with USB port mapping on your NAS. It is also possible to use the USB Stick on any notebook with python installed. That is easier to exclude any connection issues or VM USB map settings. Simply copy the pybecker subfolder to your notebook, browse to the folder and type in the command line python pybecker -m -? to get a help. Use python pybecker -m -l 10 to log any received commands for 10 seconds. You can also pair the USB stick using this command line option. This does not solve your issues with the VM, but you can use this to verify the functionality of the USB stick and your covers. If you use a Windows notebook your need to check the device manager for the right USB path like COM3. Use the -d option to change the default USB stick path python pybecker -m -d COM3 -l 10 . Don't forget to add python to PATH during installation of python (if not already done).

mngsps commented 1 year ago

OK, will try the extension cable first and will then go on. But I'm not sure I can handle this, never tried to use python like described... (I only have simple copy&paste and try&error programming skills...).

When changing USB settings, I always did restarts of HA or the whole VM (you cannot change USB setting in Synology's Virtual Machine Manager while the VM is running...). Is it necessary to restart the whole Diskstation NAS after connecting the stick? I only restarted VM and HA...

Do you think this ist the right configuration?

 - platform: becker
    device: "/dev/serial/by-id/usb-Becker-Antriebe_GmbH_CDC_RS232_v125_Centronic-if00"
    covers:
      dachfenster_bad_og:
        friendly_name: "Dachfenster Bad"
        channel: "1:1" 

Accoring to HA, the stick should be connected correctly, right?

image

image

Or should I try another device path? Any other users that have successfully connected the stick with HA running as VM on a Synology Diskstation?

All the best and thank you for the help Benedikt

RainerStaude commented 1 year ago

Read here and here to ensure you did not got Peters broken Stick 😏 But I don't see anything wrong in your configuration. You should be able so see any commands from your remotes in the log. For the experiment with the stick on your notebook there are no programming skills needed. Just copy and paste 😏. This is helpful to verify the functionality of the stick... Maybe it's a good idea to repost your question if anyone else uses Becker with NAS in the community

mngsps commented 1 year ago

Ok, big step ahead. After using an extension cable and changing the USB slot it works :-) Since I did both changes the same time, I'm not sure which one was the effective one. THANK YOU a lot for your help and efforts.

There is one remaining issue: I was able to pair both Roto windows (one with window opener, one with shutter) to channels 1:1 and 1:2. At least both reacted immediately after the pairing command sent from HA developer tools. However, only the window opener does react to commands from HA, the shutter doesn't. Remotes were configured successfully, both windows show reactions immediately in HA when using the corresponding remotes.

Distance shouldn't be an issue when pairing worked and commands from the remotes are received, right?

Any idea?

mngsps commented 1 year ago

I'm a bit confused about Units and Channels. What in general is the recommendation to use in case of two windows? 1-1 and 1-2 or 1-1 and 2-1?

Is there a mistake in the example configuration?

Basic configuration

cover:
  - platform: becker
    covers:
      # Use unique names for each cover like kitchen, bedroom or living_room
      kitchen:
        friendly_name: "Kitchen Cover"
        # Becker Centronic USB stick provides up to five units (1-5) with up to seven (1-7) channels
        # Unit 1 - Channel 2
        channel: "1"
      bedroom:
        friendly_name: "Bedroom Cover"
        # Unit 1 - Channel 2
        channel: "2"
      living_room:
        friendly_name: "Living room Cover"
        # Use Unit 2 - Channel 1
        channel: "2:1"

In this example, channel: "1" and channel: "2" both are mentioned to correspond to # Unit 1 - Channel 2...

I paired both windows like this:

Roto window with opener (does react on commands from HA):

service: becker.pair
data:
  channel: 1
  unit: 1

Roto window with shutter (does not react on commands from HA):

service: becker.pair
data:
  channel: 1
  unit: 2

My configuration is:

  - platform: becker
    device: "/dev/serial/by-id/usb-Becker-Antriebe_GmbH_CDC_RS232_v125_Centronic-if00"
    filename: "centronic-stick.db"
    covers:
      dachfenster_bad_og:
        friendly_name: "Dachfenster Bad"
        channel: "1:1"
        travelling_time_up: 44
        travelling_time_down: 51
        remote_id: "1909E:0"
      dachfenster_empore_wohnzimmer:
        friendly_name: "Dachfenster Empore Wohnzimmer"
        channel: "1:2"
        travelling_time_up: 17
        travelling_time_down: 14
        remote_id: "1EF96:0"

Is this correct or should the second cover be channel "2:1"? I tried this but then the cover was not available after restarting HA... How can one delete paired channels/units?

I'm of the opinion that pairing with the shutter worked, but the "clacks" were rather fast (more like 3 fast clacks instead of 1 followed by 2). Before solving the issue with my stick (extension cable, another slot), there was no reaction at all... Regrettably, I didn't save the log from the pairing procedure.

This is the output of the becker.log_units service:

2023-02-07 10:26:23.121 INFO (MainThread) [custom_components.becker.rf_device] Configured Becker centronic units:
2023-02-07 10:26:23.121 INFO (MainThread) [custom_components.becker.rf_device] Unit id 1, unit code 1737b, increment 134
2023-02-07 10:26:23.122 INFO (MainThread) [custom_components.becker.rf_device] Unit id 2, unit code 1737c, increment 21

And this is the output when trying to control the shutter via HA (without any reaction of the shutter):

2023-02-07 07:03:06.147 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer is travelling from position 100 to 0 in 14.0 seconds
2023-02-07 07:03:06.147 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now
2023-02-07 07:03:06.148 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer setup update ha-state callback in 14.0 seconds
2023-02-07 07:03:06.156 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 2, command: DOWN, argument: 0, packet: b'\x020000000002010B00830000001737B0210102004010\x03'
2023-02-07 07:03:09.494 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer stopped at position 77
2023-02-07 07:03:09.495 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now
2023-02-07 07:03:09.516 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 2, command: HALT, argument: 0, packet: b'\x020000000002010B00840000001737B021010200103F\x03'
2023-02-07 07:03:11.791 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer is travelling from position 77 to 100 in 3.91 seconds
2023-02-07 07:03:11.792 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now
2023-02-07 07:03:11.792 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer setup update ha-state callback in 3.91 seconds
2023-02-07 07:03:11.812 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Sent packet: unit_id: 1737B, channel: 2, command: UP, argument: 0, packet: b'\x020000000002010B00850000001737B021010200202E\x03'
2023-02-07 07:03:15.705 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now

Controlling the shutter with the remote works finde and HA does notice an track this immediately:

2023-02-06 21:39:11.881 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Received packet: unit_id: 1EF96, channel: 0, command: DOWN, argument: 0, packet: b'\x020000000002010B00000000001EF960290000004015\x03'
2023-02-06 21:39:11.881 DEBUG (Thread-2) [custom_components.becker.rf_device] Received packet for dispatcher
2023-02-06 21:39:11.882 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer received a packet from dispatcher
2023-02-06 21:39:11.883 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer is travelling from position 100 to 0 in 14.0 seconds
2023-02-06 21:39:11.883 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now
2023-02-06 21:39:11.884 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer setup update ha-state callback in 14.0 seconds
2023-02-06 21:39:12.170 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Received packet: unit_id: 1EF96, channel: 0, command: RELEASE, argument: 0, packet: b'\x020000000002010B00000000001EF960290000000055\x03'
2023-02-06 21:39:12.170 DEBUG (Thread-2) [custom_components.becker.rf_device] Received packet for dispatcher
2023-02-06 21:39:12.174 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer received a packet from dispatcher
2023-02-06 21:39:13.452 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Received packet: unit_id: 1EF96, channel: 0, command: HALT, argument: 0, packet: b'\x020000000002010B00000000001EF960290000001045\x03'
2023-02-06 21:39:13.452 DEBUG (Thread-2) [custom_components.becker.rf_device] Received packet for dispatcher
2023-02-06 21:39:13.454 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer received a packet from dispatcher
2023-02-06 21:39:13.454 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer stopped at position 89
2023-02-06 21:39:13.454 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer update ha-state now
2023-02-06 21:39:13.694 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Received packet: unit_id: 1EF96, channel: 0, command: RELEASE, argument: 0, packet: b'\x020000000002010B00000000001EF960290000000055\x03'
2023-02-06 21:39:13.694 DEBUG (Thread-2) [custom_components.becker.rf_device] Received packet for dispatcher
2023-02-06 21:39:13.696 DEBUG (MainThread) [custom_components.becker.cover] Dachfenster Empore Wohnzimmer received a packet from dispatcher
2023-02-06 21:39:15.249 DEBUG (Thread-2) [custom_components.becker.pybecker.becker_helper] Received packet: unit_id: 1EF96, channel: 0, command: UP, argument: 0, packet: b'\x020000000002010B00000000001EF960290000002035\x03'
2023-02-06 21:39:15.250 DEBUG (Thread-2) [custom_components.becker.rf_device] Received packet for dispatcher

Thank you again for helping me!

All the best Benedikt

RainerStaude commented 1 year ago

Good to hear that it is working now 😄

Indeed you paired the window opener with unit 1 channel 1 and the shutter with unit 2 channel 1. Therefore you need to change your configuration for Dachfenster Empore Wohnzimmer from channel 1:2 to 2:1:

  - platform: becker
    device: "/dev/serial/by-id/usb-Becker-Antriebe_GmbH_CDC_RS232_v125_Centronic-if00"
    filename: "centronic-stick.db"
    covers:
      dachfenster_bad_og:
        friendly_name: "Dachfenster Bad"
        channel: "1:1"
        travelling_time_up: 44
        travelling_time_down: 51
        remote_id: "1909E:0"
      dachfenster_empore_wohnzimmer:
        friendly_name: "Dachfenster Empore Wohnzimmer"
        channel: "2:1"
        travelling_time_up: 17
        travelling_time_down: 14
        remote_id: "1EF96:0"

If you want to delete the training for your Dachfenster Empore Wohnzimmer, you need to use your master remote and follow the instructions in the manual. There is a chapter "Alle Sender löschen (außer Mastersender)". After that you could re-pair Dachfenster Empore Wohnzimmer with unit 1 channel 2 if you prefer this:

service: becker.pair
data:
  channel: 2
  unit: 1
mngsps commented 1 year ago

I did change from 1:2 to 2:1 as suggested yesterday, but the this cover was not available after restart in HA (greyed out). This should have worked, right? Or is there a general misunterstanding with me and the unit/channel thing? I tought in my case I could go for 1:1 and 1:2 or 1:1 and 2:1 for pairing and it would make no difference?

RainerStaude commented 1 year ago

The first digit is the unit and the second digit the channel. Units are from 1 to 5 and channels from 1 to 7. If you only provide one digit in configuration, unit 1 is used and the number is used as channel. Therefore 1:2 and 2:1 is not the same! If the cover is greyed out something with the Becker Integration is wrong. There should be an error message in the long file. Most likely the USB stick was not available.

mngsps commented 1 year ago

Solition was, again, quite simple and I didn't get it: When changing the configuration from 1:2 to 2:1 and restarting HA, the entity of the shutter was renamed to *_2. Therefore, the entity in the dashboard was greyed out. When using the new entity it works very well! Thank you, great work!

Is it possible to change the device type of the shutter? Tried to change the opener from shutter to window but there was a failure saying it's not possible...

RainerStaude commented 1 year ago

you can use the customize section:

homeassistant:
  customize:
    cover.sonnensegel:
      device_class: shade
    cover.dachfenster_flur:
      device_class: window