[enocean] Help needed with enocean setup or automation

Hi,
I am running HA as docker on a Pi3. I want to use Enocean binary switches as user interaction for i.e. lights and other automations. I got most of the stuff running except the automation on a button press event.
I actually see the button press events in the HA logs, when using enocean debug. I created an automation with mqtt to just send a text if a button was pressed. Pretty simple, check five time by me, but it seems I am blind to my own word…
Both, automations and mqtt are working in general, tested with an other automation.
Now I hope, that you have an idea what I could test or how to fix is. I will leave you (hopefully) all interesting parts of my configurations:

Docker-compose:

services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant:stable
    volumes:
      - /home/pi/homeassistant/config:/config
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0

configuration.yaml:

...
# enocean
enocean:
  device: /dev/ttyUSB0
...
binary_sensor: !include_dir_list binary_sensors/
...
logger:
  default: error
  logs:
    homeassistant.components.enocean: debug

binary_sensors/enocean:

platform: enocean
name: test-sensor
id: [0xFE,0xEF,0xD8,0xB8]

automations:

# Automation
# this is working fine
- alias: 'Test mqtt Automation'
  trigger:
    platform: mqtt
    topic: trigger/test
    payload: "on"
    encoding: "utf-8"
  action:
  - service: mqtt.publish
    data:
      topic: trigger/response
      payload: done

# this is not working
- alias: 'Test Enocean'
  trigger:
    platform: event
    event_type: button_pressed
    event_data:
      onoff: 1
      devname: binary_sensor.test-sensor
  action:
  - service: mqtt.publish
    data:
      topic: trigger/response
      payload: enocean

home-assistant.log:

2020-10-17 15:27:15 DEBUG (Thread-3) [homeassistant.components.enocean.dongle] Received radio packet: FE:EF:D8:B8->FF:FF:FF:FF (-92 dBm): 0x01 ['0xf6', '0x70', '0xfe', '0xef', '0xd8', '0xb8', '0x30'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5c', '0x0'] OrderedDict()
2020-10-17 15:27:15 DEBUG (Thread-3) [homeassistant.components.enocean.dongle] Received radio packet: FE:EF:D8:B8->FF:FF:FF:FF (-95 dBm): 0x01 ['0xf6', '0x0', '0xfe', '0xef', '0xd8', '0xb8', '0x20'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5f', '0x0'] OrderedDict()
2020-10-17 15:27:16 DEBUG (Thread-3) [homeassistant.components.enocean.dongle] Received radio packet: FE:EF:D8:B8->FF:FF:FF:FF (-91 dBm): 0x01 ['0xf6', '0x0', '0xfe', '0xef', '0xd8', '0xb8', '0x20'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5b', '0x0'] OrderedDict()
2020-10-17 15:27:16 DEBUG (Thread-3) [homeassistant.components.enocean.dongle] Received radio packet: FE:EF:D8:B8->FF:FF:FF:FF (-95 dBm): 0x01 ['0xf6', '0x10', '0xfe', '0xef', '0xd8', '0xb8', '0x30'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5f', '0x0'] OrderedDict()

Thank you all for this project, your work and support!
Best,
nic

Can you please show an example of an event when you press the button?

I’m sorry, I don’t get your question. I am still pretty new to HA, can you guide me to that?
Is there a event log? or can I enable an event log in the logger?

Go to Developer Tools -> Events and enter * in the box “LISTENING TO EVENTS” and press start listening. Then press a button on the enocean switch and post the output of this here. If there are too many events hapening when you enter *, try putting button_pressed in the field instead.

ohhh, thanks for that. That is very usefull, I didn’t know that.
All for buttone create an event on click and relaese like they should do.
here is the output:
click:

{
    "event_type": "button_pressed",
    "data": {
        "id": [
            254,
            239,
            216,
            184
        ],
        "pushed": 1,
        "which": 0,
        "onoff": 0
    },
    "origin": "LOCAL",
    "time_fired": "2020-10-17T14:43:35.069392+00:00",
    "context": {
        "id": "2284e1ac108711eb891f3bca3bf3d4bc",
        "parent_id": null,
        "user_id": null
    }
}

and release:

{
    "event_type": "button_pressed",
    "data": {
        "id": [
            254,
            239,
            216,
            184
        ],
        "pushed": 0,
        "which": 0,
        "onoff": 0
    },
    "origin": "LOCAL",
    "time_fired": "2020-10-17T14:43:35.675800+00:00",
    "context": {
        "id": "22e16969108711eb89599b74ad782285",
        "parent_id": null,
        "user_id": null
    }
}

Ok, try this for your event trigger for button pressed:

trigger:
    platform: event
    event_type: button_pressed
    event_data:
      id: [254, 239, 216, 184]
      pushed: 1

And for release replace pushed: 1 with pushed: 0. If the switch has multiple buttons, you also need to add which: 0 or which: 1,depending on which of the buttons has been pressed.

thank you Burningstone!
unfortunately, it did not work. still the automation is not triggered.

put of curiosity:
Is there a difference for HA in using dec or hex?

Could be, I don’t use enocean. Try with the id that you have in the config for the binary sensor.

no luck with that…

Just for fun, allow it to trigger for any button-press:

  trigger:
    platform: event
    event_type: button_pressed

If that works, constrain it slightly and see if it still works:

  trigger:
    platform: event
    event_type: button_pressed
    event_data:
      pushed: 1

If both of the tests work, then the problem may be due to the trigger’s inability to handle this properly:

      id: [254, 239, 216, 184]

I just used the examole from the docs here.

Thank you guys!
Yesterday, I had an issue with docker and -compose. today, after an complete reinstall of raspberry OS, I could run the tests 123 Taras proposed and got a error while executing the automation. I missed to comment out an additional entity_id. Actually, I should have seen the same yesterday but I didn’t… there was no error.
Three possibilities for what fixed my error (or any combination :thinking:):

  1. something wrong on the miniSD Card -> fixed by the reinstall (seems unlikly to me)
  2. the automation.yaml line endings were set to CR/LF -> changed to LF
  3. the additional entity_id that should not have been there -> commented out

now my automation looks like this:

- alias: 'Test Enocean'
  trigger:
    platform: event
    event_type: button_pressed
    event_data:
      id: [0xFE,0xEF,0xD8,0xB8]
      #id: [254, 239, 216, 184] BOTH are valid / tested
      pushed: 1
  action:
  - service: mqtt.publish
    data:
      topic: trigger/response
      payload: enocean

Where is this “additional entity_id” in your original example you posted above?

not there… I wanted to make it as readable and minimal as possible and trip myself up.

You mean what you asked people to examine and fix is not what you were actually using?

Your version contained other data, like that ‘additional entity_id’?

I learnt my lesson on this one.

In my opinion, I would not mark your post with the Solution tag. Anyone else with a similar problem is likely to be misled if they follow what you did to “solve” the problem.

Recommending to re-install the operating system and Home Assistant is reserved for fixing very obvious cases of system corruption and there’s no evidence that this issue was due to that. In addition, the problem, as originally defined, left out an important detail that doesn’t appear anywhere in this thread until the so-called Solution post. This in itself misleads others about what the problem is all about.

1 Like