Enocean switch

Hi Dani

For my first attempts I also used FHEM between HA and the enocean devices. Both systems FHEM and HA are complete home automation systems, so to cascade them doesn’t seem very fancy to me. But to use MQTT between HA and enocean seems to be the best way as long as the HA included enocean integration doesn’t support our devices. (I would implement it if I could, but I’m also not a developer).

The way I described above doesn’t need two RPIs, you can run HA, mosquitto, and the named enocean-mqtt gateway from romor on the same RPI. What you need are two enocean dongles, two USB300 will also work. The reason is, that the dongle communication is done by UART (tty device), and while the enocean-mqtt gateway uses the interface, you can’t use it by another application as command line scripts.

According to romor’s description, it should also be possible to send commands from HA through enocean-mqtt to enocean devices, I’m still testing. If it works, the command line scripts as the second dongle will be obsolete.

By the way, I also integrated FSG71/1-10V from Eltako.

Hi @cgrueter

Cool!! Sounds very promising! And that fact that you have it up and running is important to me. More on that below.

I just achieved a milestone myself. I could get my TF61D to work with the standard HA enocean integration and control it from lovelace! Instead of configuring it as a switch I defined it as a light according to https://www.home-assistant.io/integrations/enocean/#light (don’t know why I thought it should be a switch beforehand…)

All of a sudden I got status updates in HA when controlling the TF61D with some enocean wall switch (Omnio and Feller) (btw, the wording “switch” is confusing as from an enocean/HA perspective it’s used differently than in plain English…)
Thus the only thing left was to teach the TF61D to “listen” to the USB dongle and ultimately to the HA commands. In the TF61D manual it said that you should send a certain teach in telegram (0xE0400D80) when connecting rotary switches or “GFVS”. Since GFVS is some kind of software I figured this could be similar to HA. However, I don’t know how to send specific telegrams with the USB dongle via HA. So I downloaded DolphinView from enocean.com, installed it on my Windows computer, connected the USB dongle to the computer, put the TF61D in teach-in mode and sent the above telegram from DolphinView. Then I reconnected the USB dongle to the RPI - and here you go!

Why is this a major milestone to me? Since we’re about to build a house I’m trying to find an affordable solution for the whole electricity installation that works without (!) home automation and any respective server etc. However, that installation should be able to be integrated in a home automation solution that I set up myself later on.
I like the whole enocean standard due to the self-power feature. It is perfect to later include window sensors and similar stuff. Or to simply install a new wall mounted switch. For my use case, this is an advantage over Zigbee or Z-Wave.
So what I have now is a proof of concept that this works: I can start with plain enocean, then extend with HA later on. However, my “simple” way HA isn’t able to cover all the enocean devices on the market yet.

Nevertheless, I believe (hope…) that over time, more devices will be supported. I even have some python dev friends, so I might be able to get one of them to help.
In the meantime or as an alternative, I might ask you for some support on how to get your setting up and running. I still need to figure out how to run a simple script from GitHub…

Hi @cgrueter

You might want to check out my post here: EnOcean - Configure FUD61, how to get 'sender_id'

I got the Eltakto enocean actors working directly with the “standard” HA enocean integration - but by doing the teaching in via a PC.

What I haven’t tried so far is to integrate enocean sensors.

Cheers
Dani

Hi Dani

Okay I see, I should try again the original HA enocean integration, there are some changes since I tested i last time. :slightly_smiling_face:
I will play around with it and give a feedback as soon as I found the time doing that. :timer_clock:

For the teach-in I tinkered some lines of Python code:

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from enocean.consolelogger import init_logging
import enocean.utils
from enocean.communicators.serialcommunicator import SerialCommunicator
from enocean.protocol.packet import RadioPacket
from enocean.protocol.packet import Packet
from enocean.protocol.constants import PACKET, RORG
import sys, time

try:
    import queue
except ImportError:
    import Queue as queue

sender_id=[0xAA, 0xAA, 0xAA, 0xFF]

destination_id=[0xFF, 0xFF, 0xFF, 0xFF]

def assemble_packet_press_a_1():
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=0, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_a_0():
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=1, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_b_1():
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=2, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_b_0():
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=3, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_release():
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=0, EB=0, R2=0, SA=0, T21=True, NU=False)

init_logging()
communicator = SerialCommunicator(port='/dev/ttyUSB0')
communicator.start()
time.sleep(1.5)
communicator.send(assemble_packet_press_a_1()) #a_1
time.sleep(0.2)
communicator.send(assemble_packet_release())
time.sleep(0.3)
communicator.send(assemble_packet_press_a_1()) #a_1
time.sleep(0.2)
communicator.send(assemble_packet_release())
time.sleep(1.5)
communicator.stop()

The script simulates pressing two times the “a1” rocker of a double rocker. I think it’s self explaining what’s to change if you only have to simulate one click or if you want to use the “b” rocker. If I remember correct, I used the example script from kipe as base Idea for this script, maybe it’s also useful for you.
It’s important to change the sender_id, the first three codes have to correspond to the base id of your USB enocean dongle (or enocean pi).

Exactly same reasons why I use enocean: Works without central “head” device, no batteries, no dedicated network needed (WLAN), very short telegram (collision avoidance), Feller Design available.

Have fun with enocean and Home Assistant.

Hello, I am interested by this topic : indeed my project would be to control my roller shutter with Home Assistant.
My equipement is 1) Nodon Soft Remote control (ENOCEAN EEP F6-02-02) and Eltako FSB61NP for the roller shutter). I have found the sender_ID of my remote control with HEXDUMP and a Enocean PI on my Rpi.
But, the Enocean module of Home Assistant seems not to be able to treat this project.
I am a beginner in domotic, but quite interested, I am motivated to improve myself, and I was wondering if someone has succeeded to control his rollet shutter with HA ? with MQTT ? I don’t understand how HA can send an action to my Eltako
I thank you in advance for your answers

Hello, I have progressed beeing able to command my eltako FSB61NP (for cover shutter) from HA via MQTT FHEM.
But I would like to directly command from HA via enocean2mqtt.
I have an enoceanpi (and not a key USB300) so not able to use dolphin on a PC.
But maybe I can use the parameters from FHEM to configure enocean2mqtt.
Do you have some tuto or explanations so as to use enocean2mqtt using information such as below ?
Thank you in advance for your help

Hi

In between I wrote some chaotic python spaghetti code. :smirk:
It would be great if there is any python developer who is able to help me/us.

With the following python code I’m able to control my roller shutters by Home Assistant (Omnio UPJ230/12, sending EEP F6-02-02, receiving feedbak EEP D2-05-00). It shows the correct status (open, close, position) and I’m able to open and close them from Home Assistant.

The code uses again the kipe/enocean library and is based on the example code there.
Basically it’s also a Home Assistant -> MQTT -> Enocean gateway and vice versa.
It takes the sender ID of the enocean actuator and create the Home Assistant entities and the configuration of them by the Home Assistant MQTT discovery function. I only have to place the configured entities on the Home Assistant GUI from the “unused entities” list.
My USB enocean dongle sender IDs are teached in into the shutter actuator with the above described “teach in” script, and the actuator are configured sending periodically a feedback VLD telegram.

I also wrote the same chaotic python spaghetti code for enocean window contacts, light actuator and switch actuator. Maybe I should upload the scripts on GitHub, so that you can adjust and use it for your own application.

@Christianb233: Belong the data sheet of eltako FSB61NP you are only able to send commands to this roller shutter actuator, but not to receive state and position feedbacks?

Have fun with enocean and Home Assistant.

#/usr/local/bin/python3.7
# -*- encoding: utf-8 -*-
from enocean.consolelogger import init_logging
from enocean.communicators.serialcommunicator import SerialCommunicator
from enocean.protocol.packet import RadioPacket
from enocean.protocol.packet import Packet
from enocean.protocol.constants import PACKET, RORG
import enocean.utils
import traceback
import sys, time, queue, logging
import paho.mqtt.client as mqtt


mqttBroker = "10.0.0.99"
mqttUsername = "mqtt-user"
mqttPassword = "mqtt-secret"
mqttClientId = "enocean_gateway"
enocean_port="/dev/ttyUSB0"

# Pace your shutter ID and names here
rollo_actors = {'01:75:C9:FE' : 'rollo_nord'}
# or here, if open close is reversed, as the most of mines :-)
rollo_actors_v = {'01:77:30:3A' : 'rollo_west_1',
                  '01:75:BB:76' : 'rollo_west_2',
                  '01:72:60:48' : 'rollo_south_1',
                  '01:72:64:C0' : 'rollo_south_2'}
init_logging()

destination_id=[0xFF, 0xFF, 0xFF, 0xFF]
sender_id=[0xAA, 0xAA, 0xAA, 0x00]

def assemble_packet_press_a_1(sender_id):
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=0, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_a_0(sender_id):
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=1, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_b_1(sender_id):
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=2, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_press_b_0(sender_id):
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=3, EB=1, R2=0, SA=0, T21=True, NU=True)

def assemble_packet_release(sender_id):
    return Packet.create(packet_type=PACKET.RADIO, rorg=0xF6, rorg_func=0x02, rorg_type=0x02, 
                         destination=destination_id, sender=sender_id, R1=0, EB=0, R2=0, SA=0, T21=True, NU=False)

def on_mqtt_connect(client, userdata, flags, rc):
  if rc==0:
    print("Connection to "+mqttBroker+" successful, Returned code=",rc)
    mqttclient.connected_flag=True
  else:
    print("Bad connection Returned code=",rc)

def on_mqtt_disconnect(client, userdata, rc):
  print("disconnecting reason " +str(rc))
  mqttclient.connected_flag=False
  mqttclient.disconnected_flag=True

def on_mqtt_message(client, userdata, message):
  print("Received Topic:",message.topic,"Message",message.payload)
  if message.topic=="homeassistant/cover/enocean/rollo_west_1/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_0([0xAA, 0xAA, 0xAA, 0x32])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_1([0xAA, 0xAA, 0xAA, 0x32]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
  if message.topic=="homeassistant/cover/enocean/rollo_west_2/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_0([0xAA, 0xAA, 0xAA, 0x35])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_1([0xAA, 0xAA, 0xAA, 0x35]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
  if message.topic=="homeassistant/cover/enocean/rollo_south_1/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_0([0xAA, 0xAA, 0xAA, 0x30])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_1([0xAA, 0xAA, 0xAA, 0x30]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
  if message.topic=="homeassistant/cover/enocean/rollo_south_2/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_0([0xAA, 0xAA, 0xAA, 0x34])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_1([0xAA, 0xAA, 0xAA, 0x34]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
  if message.topic=="homeassistant/cover/enocean/rollo_nord/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_1([0xAA, 0xAA, 0xAA, 0x33])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_0([0xAA, 0xAA, 0xAA, 0x33]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())

def connect_messages():
  for k in rollo_actors:
    mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors[k]+"/config",'{"name" : "'+rollo_actors[k]+'", "device_class" : "shutter", "command_topic" : "homeassistant/cover/enocean/'+rollo_actors[k]+'/set", "set_position_topic" : "homeassistant/cover/enocean/'+rollo_actors[k]+'/set_position", "position_topic" : "homeassistant/cover/enocean/'+rollo_actors[k]+'/position", "uniq_id" : "'+k+'", "avty_t" : "homeassistant/cover/enocean/'+rollo_actors[k]+'/availability", "exp_aft" : "600"}', retain=True)
    mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors[k]+"/availability","online",retain=True)
    mqttclient.subscribe([("homeassistant/cover/enocean/"+rollo_actors[k]+"/set", 0), ("homeassistant/cover/enocean/"+rollo_actors[k]+"/set_position", 0)])
  for k in rollo_actors_v:
    mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors_v[k]+"/config",'{"name" : "'+rollo_actors_v[k]+'", "device_class" : "shutter", "command_topic" : "homeassistant/cover/enocean/'+rollo_actors_v[k]+'/set", "set_position_topic" : "homeassistant/cover/enocean/'+rollo_actors_v[k]+'/set_position", "position_topic" : "homeassistant/cover/enocean/'+rollo_actors_v[k]+'/position", "uniq_id" : "'+k+'", "avty_t" : "homeassistant/cover/enocean/'+rollo_actors_v[k]+'/availability", "exp_aft" : "600"}', retain=True)
    mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors_v[k]+"/availability","online",retain=True)
    mqttclient.subscribe([("homeassistant/cover/enocean/"+rollo_actors_v[k]+"/set", 0), ("homeassistant/cover/enocean/"+rollo_actors_v[k]+"/set_position", 0)])

mqtt.Client.connected_flag=False
mqtt.Client.disconnected_flag=True
mqttclient = mqtt.Client(mqttClientId)
mqttclient.on_connect=on_mqtt_connect
mqttclient.on_disconnect=on_mqtt_disconnect
mqttclient.username_pw_set(username=mqttUsername,password=mqttPassword)
mqttclient.connect(mqttBroker)
mqttclient.loop_start()
mqttclient.on_message=on_mqtt_message

communicator = SerialCommunicator(enocean_port)
communicator.start()

# endless loop receiving radio packets
while communicator.is_alive():
  if mqttclient.disconnected_flag:
    connect_messages()
    print("Connect Messages sent")
    mqttclient.disconnected_flag=False
  while not mqttclient.connected_flag:
    print("Waiting for reconnect")
    time.sleep(1)
  try:
    # Loop to empty the queue
    packet = communicator.receive.get(block=True, timeout=1)
    if packet.packet_type == PACKET.RADIO_ERP1 and packet.rorg == RORG.VLD:
      packet.select_eep(0x05, 0x00)
      packet.parse_eep()
      if packet.sender_hex in rollo_actors_v:
        #print("*** Got rollo feedback --> :", rollo_actors_v[packet.sender_hex], packet.parsed['POS']['raw_value'])
        mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors_v[packet.sender_hex]+"/position", 100-packet.parsed['POS']['raw_value'],retain=False)
      elif packet.sender_hex in rollo_actors:
        #print("*** Got rollo feedback --> :", rollo_actors[packet.sender_hex], packet.parsed['POS']['raw_value'])
        mqttclient.publish("homeassistant/cover/enocean/"+rollo_actors[packet.sender_hex]+"/position", packet.parsed['POS']['raw_value'],retain=False)
      else:
        print("New unknown VLD telegram: ")
        for k in packet.parsed:
          print('%s: %s' % (k, packet.parsed[k]))
    if packet.packet_type == PACKET.RADIO_ERP1 and packet.rorg == RORG.BS4:
      print("New unknown BS4 telegram: ")
      for k in packet.parse_eep(0x02, 0x05):
        print('%s: %s' % (k, packet.parsed[k]))
    if packet.packet_type == PACKET.RADIO_ERP1 and packet.rorg == RORG.BS1:
      packet.select_eep(0x00, 0x01)
      packet.parse_eep()
      print("New unknown BS1 telegram: ")
      for k in packet.parsed:
        print('%s: %s' % (k, packet.parsed[k]))
    if packet.packet_type == PACKET.RADIO_ERP1 and packet.rorg == RORG.RPS:
      packet.parse_eep(0x02, 0x02)
      print("New unknown RPS telegram: ")
      for k in packet.parsed:
        print('%s: %s' % (k, packet.parsed[k]))
  except queue.Empty:
    continue
  except KeyboardInterrupt:
    break
  except Exception:
    traceback.print_exc(file=sys.stdout)
    break

if communicator.is_alive():
  communicator.stop()
  print("Communicator stoped.")

mqttclient.loop_stop() 
print("MQTT loop stoped")
mqttclient.disconnect()
print("MQTT client disconnected")

Nice script!

How do you run it?
I am using hass.io and could use pyscript or appdeamon to run python sripts.

You really have to run it on a console. It shows you a lot of information, for example not configured sender IDs of your sensors and actuators, so that you can add them in the script. The script can also be run on an other computer than the home-assistant system, it needs an enocean dongle and a connection to the MQTT broker.
In between I uploaded a new version: https://github.com/cgrueter/enohag
This version supports shutter actuators, light/switch actuators (Omnio UPS230, Omnio UPD230), window contacts and rocker.

1 Like

Hi all, hi cgrueter,

It seems to be a really good script !
I was using Domoticz for a while, and wanted to change for Home Assistant that has a nicer interface. Unfortunately, I have some Ubiwizz roller shutter module (very similar to NodOn modules, SIN-2-RS-01 using EEP D2-05-00), and it is not natively usable with Hassio.

This script seems to be a good alternative (I have read that FHEM could also be used with MQTT, but this python script seems easier to install).

Could you please explain how to use it ? As asked cubertt, can it be used with hassio, or should I install Home Assitant supervised ?

Many thanks in advance !

i think he is running the script on an additional raspberry or else.

i tried it, but it is not simple.

What i found out the last week, is that:

Homeassistant can use/install node-red as a addon (and integration, i believe)

Node-red has an addon for enocean.

So i am trying now to get the enocean addon/node running in node red (in the moment on an second raspberry) and then use it in hass.io with the hass.io node red addon and integration.

Here the links:
Example of using it:

link to the node red addon:

1 Like

That seems to be also a good alternative, thanks for sharing !

I have tried to start node-red (never used it to be honnest) add-on in Hassio directly.
After several tries, and some errors read, I got it running with the enocean add-on in Node-red.

Here is the configuration file I used in Hassio Node-red addon, for information:

credential_secret: 'secret_credential!'
dark_mode: false
http_node:
  username: ''
  password: ''
http_static:
  username: ''
  password: ''
ssl: true
certfile: certificate.pem
keyfile: privkey.pem
require_ssl: true
system_packages:
  - make
  - python3
  - g++
  - gcc
  - linux-headers
npm_packages:
  - nan
  - serialport
  - node-red-contrib-enocean
init_commands: []
log_level: info

I had to generate an SSL certificate, but you can avoid this task putting “ssl: false” and “require_ssl: false”.

Also, to have the enocean addon working properly, it is necessary to add the following code in the settings.js file, normally stored in /config/node-red

contextStorage: {
   default: {
       module: "localfilesystem"
   }
}

I will let you know if there is any other progress.

1 Like

Hi RCasa

Ok, I added some explanations on the above named github.

Our long term collective goal should be to help to improve the native enocean Home Assistant integration, so that we don’t need any additional tool or script. I would if could, but I can’t. :wink:

1 Like

Hi !

I completely agree with your point of view @cgrueter. The problem is that I have no skill in programing (or low level), so I am not able to help to improve the native enocean Home Assistant. Nevertheless, what I can do is trying to find alternative solutions that could be implemented easily ! (Or at least with a detailed procedure).

I had good progress on my side today: I was able to create the nodes in Node-red and get a status from my roller shutter when I moved it. I am not able to control it up to now, but I was able to see the communication between the roller shutter module using EEP D2-05-00 and the USB300 key connected to my raspberry.
For info: I already paired my module when I was using Domoticz.

I have same “problem”:
Teach in was done with openhab, now i need to translate senderIDOfsett (from Openhab) to the sender ID’s from cgrueter / enocean python script.

Here a Question: in your description on github (thanks!) your write “Every enocean dongle has it’s ownd base ID” but in the script i am reading:

destination_id=[0xFF, 0xFF, 0xFF, 0xFF]
sender_id=[0xAA, 0xAA, 0xAA, 0x00]

should i change at least the first 3 “numbers” to the one i read from my dongle? (e.g. 0xFF,0xF6,0x9B,0xXX)

And of course these workarounds are just that, workarounds. Please devs, include a good enocean addon!

Correct, if you want to send a command to an actuator, then you have to get your base ID of your dongle and add the “offset”.

Following steps are needed to be able to send commands:

  1. Get your base ID, to do this by using the enohag.py python script, put the following line of python code into the enohag.py script after communicator.start()
print('Your base ID: %s.' % enocean.utils.to_hex_string(communicator.base_id))
  1. After starting the script, it will show you an output as the following example:
    Your base ID: FF:F6:9B:00.
    That means, that your valid sender IDs are FF:F6:9B:00, FF:F6:9B:01, FF:F6:9B:02 … FF:F6:9B:FF
  2. Teach in one of this valid sender IDs in one of your actuator, then an other valid sender ID in another actuator and so on. You can use the above shown “teach in” script to do this step, or any other teach in tool. As I understand you, you have done this step already.
    For example you teach in FF:F6:9B:01 in your fist roller shutter.
  3. The declaration
    destination_id=[0xFF, 0xFF, 0xFF, 0xFF]
    doesn’t matter, it simply means “broadcast” to all enocean receivers. All my enocean actuators accept that. I think that this is true for almost all enocean actuators. Anyway it’s radio communication and every actuator is listening to all communication.
  4. The declaration
    sender_id=[0xAA, 0xAA, 0xAA, 0x00]
    honestly also doesn’t really matter at this point, it will be overwritten by the sender IDs in the def on_mqtt_message function. You can put here your base ID for your documentation:
    sender_id=[0xFF, 0xF6, 0x9B, 0x00]
    but again, it does nothing.
  5. Most important step now is, that you adjust the def on_mqtt_message function:
  if message.topic=="homeassistant/cover/enocean/rollo_west_1/set":
    if message.payload.decode('UTF-8')=='OPEN':
      communicator.send(assemble_packet_press_a_0([0xFF, 0xF6, 0x9B, 0x01])) #Teached in sender ID for this shutter
      time.sleep(0.1)
      communicator.send(assemble_packet_release())
    if message.payload.decode('UTF-8')=='CLOSE':
      communicator.send(assemble_packet_press_a_1([0xFF, 0xF6, 0x9B, 0x01]))
      time.sleep(0.1)
      communicator.send(assemble_packet_release())

First, rollo_west_1 in homeassistant/cover/enocean/rollo_west_1/set must correspond with your description in the beginning of the script, and second, here you have to set two times, the correct teached in sender ID, in our example 0xFF, 0xF6, 0x9B, 0x01

1 Like

Regarding your installation, are you running 2 raspberry pi ? (One with Home Assistant, and another one with your MQTT broker, the Encoean dongle, and the script running ?).

If yes, do you think there any possibility to have everything running on the same raspberry ?

Three of them. :grin:

  1. Home Asssistant
  2. MQTT broker
  3. System with USB 300 enocean dongle, running the enohag.py script

You should be able to run all things together on one raspberry pi, I don’t see any reason why that shouldn’t work.

Great, thanks for the input.

I have an error, when sending OFF or ON via mqtt explorer to one switch:

Connection to 192.168.1.12 successful, Returned code= 0
2021-02-25 22:11:58,884 - enocean.communicators.SerialCommunicator - INFO - SerialCommunicator starte                                                                                                                                        d
Connect Messages sent
Received Topic: homeassistant/light/enocean/light_one/set Message b'ON'
2021-02-25 22:12:00,893 - enocean.communicators.SerialCommunicator - INFO - Sending packet
2021-02-25 22:12:00,893 - enocean.communicators.SerialCommunicator - DEBUG - FF:F6:9B:01->FF:FF:FF:FF                                                                                                                                         (-255 dBm): 0x01 ['0xf6', '0x10', '0xff', '0xf6', '0x9b', '0x1', '0x30'] ['0x3', '0xff', '0xff', '0x                                                                                                                                        ff', '0xff', '0xff', '0x0'] OrderedDict([('R1', {'description': 'Rocker 1st action', 'unit': '', 'val                                                                                                                                        ue': 'Button AI', 'raw_value': 0}), ('EB', {'description': 'Energy bow', 'unit': '', 'value': 'presse                                                                                                                                        d', 'raw_value': 1}), ('R2', {'description': 'Rocker 2nd action', 'unit': '', 'value': 'Button AI', '                                                                                                                                        raw_value': 0}), ('SA', {'description': '2nd action', 'unit': '', 'value': 'No 2nd action', 'raw_valu                                                                                                                                        e': 0}), ('T21', {'description': 'T21', 'unit': '', 'value': True, 'raw_value': 1}), ('NU', {'descrip                                                                                                                                        tion': 'NU', 'unit': '', 'value': True, 'raw_value': 1})])
2021-02-25 22:12:00,908 - enocean.communicators.SerialCommunicator - ERROR - Serial port exception! (                                                                                                                                        device disconnected or multiple access on port?)
2021-02-25 22:12:00,908 - enocean.communicators.SerialCommunicator - INFO - SerialCommunicator stoppe                                                                                                                                        d
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3452, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1779, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1181, in loop
    rc = self.loop_read(max_packets)
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1572, in loop_read
    rc = self._packet_read()
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2310, in _packet_read
    rc = self._packet_handle()
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2936, in _packet_handl                                                                                                                                        e
    return self._handle_publish()
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3216, in _handle_publi                                                                                                                                        sh
    self._handle_on_message(message)
  File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_me                                                                                                                                        ssage
    self.on_message(self, self._userdata, message)
  File "enoceanneu.py", line 78, in on_mqtt_message
    communicator.send(assemble_packet_release())
TypeError: assemble_packet_release() missing 1 required positional argument: 'sender_id'

MQTT loop stoped
disconnecting reason 0
MQTT client disconnected

Can you help?

There seems to be another process accessing the enocean dongle. It is not possible access more than once simultaneously to a serial port (the enocean dongle is a serial port device).
If you run the script on the same system as Home Assistant, and if you still have the enocean integration configured in Home Assistant, than Home Assistant is also accessing the enocean dongle.
Try to remove the enocean integration and restart Home Assistant.

The sender ID was missing in the button release message, now I did an update and I’m wondering why the script was working before. :yum: