# \[V4\] Enocean Integration

**URL:** <https://community.gladysassistant.com/t/v4-integration-enocean/5476>\
**Category:** Développement\
**Created:** [August 1, 2020, 9:01am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476 "2020-08-01T09:01:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 1, 2020, 9:01am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/1 "2020-08-01T09:01:50Z")

</div>

Hi Pierre-Gilles,

I’ve been quite absent from Gladys for a few months, but I would like to resume the integration work of the enocean protocol on Gladys 4.

However, the enocean-js module doesn’t really suit me, the guy who develops it does a great job but he’s alone, there’s no documentation and I’m struggling a lot…

Since I do a lot of Python at work, I’m looking at Python and I find things I would like to experiment with.  
But in this case, it would rather be in the form of a remote module based on MQTT exchanges.

What would be the right approach on the Gladys side? Should I develop a Gladys integration in charge of the discussion via MQTT with Python/Enocean or is there a standard interface for this?

I admit that I haven’t really looked into V4 yet, but it’s time to get started 😃

See you soon,

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 3, 2020, 7:00am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/2 "2020-08-03T07:00:37Z")

</div>



---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 3, 2020, 7:12am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/3 "2020-08-03T07:12:52Z")

</div>

Hello @Jean-Philippe!

I made your post public so that everyone can see it 🙂

**So three options:**

1. In itself, you could very well call Python code from Gladys and keep this integration in Gladys. After all, if it’s really a Python program running permanently, that’s not great.

2. You can take inspiration from what has been done on the zigbee2mqtt module, which is a service whose work is done by a Docker container that communicates with Gladys via MQTT. You would therefore need to develop the remote service, create a UI in Gladys to control everything, and develop an MQTT API between the two so that they can communicate. After that, in the zigbee2mqtt module, this was done because zigbee2mqtt is an external project that we do not control and which has done a great job of converting zigbee messages from many integrations into MQTT.

3. Dive into the enocean-js code and make a native integration in Gladys.. 🙂 I went to look at the [enocean-js](https://github.com/enocean-js/enocean-js) repository, I expected an abandoned project and frankly it looks solid and well designed. V4 is not V3, the goal of V4 is to design a public software that is easy to use and works «&nbsp;out of the box&nbsp;». A native integration when possible, **it changes everything**.

You can take inspiration from other projects that use enocean-js like [node-red-contrib-enocean](https://github.com/enocean-js/enocean-js/tree/master/packages/node-red-contrib-enocean), the code is readable and I think we could quite simply transpose that into Gladys 🙂

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 23, 2020, 8:21pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/4 "2020-10-23T20:21:16Z")

</div>

I’ve finally started developing an Enocean integration.  
After a few hours of banging my head to understand how V4 works, I have a service that starts and connects to my USB dongle 🤠

I’m going to try to integrate the [enocean-js](https://github.com/enocean-js/enocean-js) module directly into gladys, which is a bit of a challenge, but it’s the ability to support all the existing equipment variety… so I’ll start by seeing how to support simple sensors (like temperature, motion, etc.) and then we’ll go step by step.

What I can do is push my branch to git and maybe you could tell me if it’s «&nbsp;Gladys compliant&nbsp;» what I’ve started. I started from the Z-wave integration.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 24, 2020, 1:36pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/5 "2020-10-24T13:36:17Z")

</div>

A question about device management and their features.

When looking at the Xiaomi and Zwave integrations, I get the impression that when a value is received from a sensor, a message is sent to Gladys with the type EVENTS.DEVICE.NEW\_STATE by systematically reconstructing the device object?

I thought I should first register the known / paired / registered / scanned devices before being able to send / receive data.

I’m a bit lost on the algorithm to write.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 26, 2020, 7:22am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/6 "2020-10-26T07:22:31Z")

</div>

Hello @Jean-Philippe! Great for this EnOcean module 🙂

> [@Jean-Philippe](#):
>
> Is it necessary to send a message to Gladys with the type EVENTS.DEVICE.NEW\_STATE by systematically reconstructing the device object?

No, you just need to emit an event with the external\_id of the device (the unique identifier on the EnOcean side) and the new state.

Example in the case of the Xiaomi service:

> <https://github.com/GladysAssistant/Gladys/blob/master/server/services/xiaomi/lib/event/xiaomi.newValueCube.js#L88>

> [@Jean-Philippe](#):
>
> I thought I first had to register the known/paired/registered/scanned devices before being able to send/receive data.

That’s exactly what you need to do, take inspiration from the Z-Wave service for example. There are 2 tabs: 1 tab for devices that are already connected to Gladys, and a tab to connect new Z-Wave devices to Gladys.

If there’s anything else you don’t understand, don’t hesitate 🙂

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 26, 2020, 7:35am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/7 "2020-10-26T07:35:09Z")

</div>

thanks, I’m getting better and better as I go along.  
My repo if you want to take a look and tell me if I’m on the right track:

[https://github.com/Jean-PhilippeD/Gladys/tree/enocean](https://github.com/Jean-PhilippeD/Gladys/tree/enocean)

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 26, 2020, 8:38pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/8 "2020-10-26T20:38:36Z")

</div>

If I look at the Xiaomi example.

It’s the addDevice.js function that emits an event with the new device in the payload. But I don’t understand how gladys registers this device in the db..? I don’t see the call to gladys.device.create()

Only the front seems to listen to the XIAOMI.NEW\_DEVICE event and if I understand correctly, just to reload the list of devices?

There are still things I don’t understand 😃

For the moment, in what I’ve written, I call gladys.device.create() myself, I don’t go through an event.

I would appreciate some clarification here 😛

Edit: Ok I just saw action.js on Xiaomi … I understand better… I will take inspiration from it!

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 27, 2020, 8:00am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/9 "2020-10-27T08:00:00Z")

</div>

> [@Jean-Philippe](#):
>
> Only the front seems to listen to the XIAOMI.NEW\_DEVICE event and if I understand correctly, just to reload the device list?

In fact, in Gladys v4, it’s never the backend that creates the devices: it’s too obscure, and in case of error, we have no feedback.

In Gladys v4, it’s the UI that is at the center of the product. It’s the front that calls the device creation route!

For the EnOcean service, rather take inspiration from the Z-Wave service which is closer.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [February 25, 2021, 3:33pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/10 "2021-02-25T15:33:51Z")

</div>

Hello Pierre-Gilles,

I’m finally trying to get back to work on Gladys… this time it’s going to happen 😃  
Currently, I’m doing development at work, so in the evening I struggle to do more development… except that V3 is running out of steam… I have a lot of Enocean equipment that I’m not using, and it’s frustrating…

I even considered testing Jeedom… no but seriously…

So I gathered my courage and just got my hands back in the gears!

I resumed the development of the Enocean integration, and it’s starting to look like something, I’m more comfortable with the code structure.

I managed to add devices and see them correctly in the dashboard.

I still need to:

- manage more equipment profiles.
- handle messages when a device sends something
- send a message to a device
- write the tests

I have good hope to have something functional quickly!  
And after that, I have no more integration to do on what I had done in V3 that I use daily 😉 (essential to migrate and turn off V3 at home)

Here’s a bit of news, I hope I won’t fall into a black hole after this email 😃

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [February 25, 2021, 4:41pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/11 "2021-02-25T16:41:45Z")

</div>

Hi Jean-Philippe 🙂

> [@Jean-Philippe](#):
>
> So I gathered my courage and just got my hands dirty again!

Yeees 🙂

Keep us updated here, and don’t hesitate if you have any questions!

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [March 14, 2021, 10:46am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/12 "2021-03-14T10:46:39Z")

</div>

Hello!

Some news.

I’ve made good progress, I’m able to retrieve values from several types of equipment.  
I’m working on equipment that can currently receive orders.

I still have tests to write as well.

I’m reaching out to Enocean device owners, could you let me know what equipment and EEP profiles you have at home?  
Because the challenge will be to support as many devices as possible.  
For information, I’m based on the enocean-js module where you can see the supported profiles here:  
[https://enocean-js.github.io/enocean-js](https://enocean-js.github.io/enocean-js)

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [March 15, 2021, 8:35pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/13 "2021-03-15T20:35:29Z")

</div>

If anyone wants to try, here is a first version on my branch.

> **[GitHub - Jean-PhilippeD/Gladys at enocean-service](https://github.com/Jean-PhilippeD/Gladys/tree/enocean-service)**
>
> A privacy-first, open-source home assistant. Contribute to Jean-PhilippeD/Gladys development by creating an account on GitHub.

Working for now:

- Temperature sensor (a5-02-05)
- Motion sensor (a5-07-01)
- Door/window opening sensor (d5-00-01)
- Rocker switch (f6-02-01)
- Wall switch (d2-01-0f)

---

<div class="post-metadata">

**Author:** ![eric2-6](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@eric2-6](https://community.gladysassistant.com/u/eric2-6)\
**Post date:** [June 16, 2021, 4:01pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/14 "2021-06-16T16:01:39Z")

</div>

Hello, I have been following your project for a long time now. I think that yes, the switches are also important, as well as micro modules like Nodon for lighting and roller shutters, which are the most important. Personally, I use Eltako equipment, which is quite comprehensive in terms of EnOcean. By the way, I will try your program when I understand how to install it lol.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [June 19, 2021, 10:10am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/15 "2021-06-19T10:10:09Z")

</div>

Hello,

Currently I have an issue making the wall switches (d2-01) work, in fact I manage to control one, but if I have several, they are all paired together, so not practical.  
I haven’t been able to progress further for the moment.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 26, 2021, 4:52pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/16 "2021-08-26T16:52:15Z")

</div>

Hey some news… it’s definitely complicated to free up time ☹

These days, I’ve motivated myself and managed to get my switches working correctly with a D2-01-00 profile.

I don’t have a module for the roller shutters @eric2-6 if you can give me a link to what you have so I can see how to integrate them.

As a result, I started looking into writing the tests, but I’m encountering problems @pierre-gilles  
I haven’t installed the zwave lib, and eslint is yelling at me about the import in the z-wave integration:

```bash
gladys-server@ pretest /home/jp/Gladys4/Gladys/server
> npm run eslint

> gladys-server@ eslint /home/jp/Gladys4/Gladys/server
> eslint .

/home/jp/Gladys4/Gladys/server/services/zwave/index.js
  7:25 error Unable to resolve path to module 'openzwave-shared' import/no-unresolved

```

So to bypass, I roughly removed the `pretest` from the npm scripts. (well I did want to install it but you also have to install the binary and I got errors at make .. so I wanted to keep it simple)

But then, I get this error:

```bash
> gladys-server@ test /home/jp/Gladys4/Gladys/server
> cross-env NODE_ENV=test ./node_modules/mocha/bin/mocha --recursive ./test/bootstrap.test.js "./test/**/*.test.js" --exit

/home/jp/Gladys4/Gladys/server/services/mqtt/node_modules/mqtt/mqtt.js:1
(function (exports, require, module, __filename,__ dirname) { #!/usr/bin/env node
                                                              ^
SyntaxError: Invalid or unexpected token
    at new Script (vm.js:100:7)

```

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 30, 2021, 9:43am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/17 "2021-08-30T09:43:11Z")

</div>

@Jean-Philippe have you managed to solve your problem?

Which version of Node.js are you using? (node -v), you should be using Node \>= 14.

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 30, 2021, 7:42pm UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/18 "2021-08-30T19:42:56Z")

</div>

Yes, I’ve resolved it. I had to take a step back and dig into it for the _n-th_ time to understand how it works. The thing is, the guy maintaining the library hasn’t responded in 6 or 7 months ☹  
The idea is that I’ll run it at my place for some time before pushing a PR. I don’t know how to share my code if others want to test it. I saw a post where you can create images via integration…

On the Node side, I’m on v14.12.0

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [August 31, 2021, 1:34am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/19 "2021-08-31T01:34:52Z")

</div>

> [@Jean-Philippe](#):
>
> the thing is that the guy who maintains the library hasn’t responded for 6 or 7 months ☹

Ah 😅 And isn’t there anything more recent in terms of the library? It’s not great for the future of the integration if the dependency is no longer maintained ^^

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [August 31, 2021, 6:08am UTC](https://community.gladysassistant.com/t/v4-integration-enocean/5476/20 "2021-08-31T06:08:38Z")

</div>

I haven’t found anything better, at least in JS, I saw a Python lib but barely more maintained 😕

[Next page](https://community.gladysassistant.com/t/v4-integration-enocean/5476.md?page=2)
