Development environment

Hello,

I am setting up a development environment to participate in testing or coding the Gladys application.

I installed this environment on a machine other than my Gladys server. The environment is on a laptop running W11, with 8GB of RAM and a 500GB HD. I am using WSL2 with Ubuntu 20.04 (although I also have Kali and Debian), I have VS Code on both W11 and Ubuntu 20.04, and I have Docker Desktop for Windows. I am following the installation procedure described in the documentation.

I installed it under my home directory in Ubuntu.

However, a few things seem strange to me:

  • I have an openzwave directory directly under my directory
  • The gladys folder is inside this openzwave folder…
  • Server installation is fine, but it seems to be stuck on check calendar, and on my browser for the address localhost:1443 I get a message: « error cannot get »
  • When viewing the server startup log with npm start, I notice many service startup errors, bluetooth, etc.
  • Frontend installation: OK, browser display OK, but issues with device integration…

For information, this PC is a development tool and includes other development environments: Delphi, WAMP, SQLite, Arduino, RStudio, Eclipse, IIS, Python…

I’m not on Windows (I’m on macOS), so I wouldn’t be of much help after that:

This already seems very strange.

Let’s look at each error one by one, but it’s normally not a problem if all integrations do not work.

Do you have more details?

Well, you must have cloned the Gladys repo in the openzwave folder

@pierre-gilles @VonOx

I took back the dev environment under wsl: there was a conflict issue, I had 2 instances of ubuntu20.04 following a Microsoft update that was in progress.
So apparently my wsl tree seems ok.

einstein@SYNAPSAT7:~/gladys$ ls -l
total 272
-rw-r--r--  1 einstein einstein 130489 Mar 15 11:45 CHANGELOG.md
-rw-r--r--  1 einstein einstein  10941 Mar 15 11:45 LICENSE
-rw-r--r--  1 einstein einstein   8875 Mar 15 11:45 README.md
-rw-r--r--  1 einstein einstein    254 Mar 15 11:45 SECURITY.md
-rw-r--r--  1 einstein einstein    145 Mar 15 11:45 codecov.yml
drwxr-xr-x  2 einstein einstein   4096 Mar 15 11:45 docker
drwxr-xr-x  7 einstein einstein   4096 Mar 15 14:39 front
-rw-r--r--  1 einstein einstein  33549 Mar 15 11:45 insomnia.json
-rw-r--r--  1 einstein einstein  59242 Mar 15 11:45 package-lock.json
-rw-r--r--  1 einstein einstein   1722 Mar 15 11:45 package.json
drwxr-xr-x 13 einstein einstein   4096 Mar 15 14:28 server

But on the server startup side npm start there is a problem:

2022-03-15T14:33:45+0100 <debug> bluetooth.start.js:14 (BluetoothManager.start) Bluetooth: Listening Bluetooth events
2022-03-15T14:33:45+0100 <error> index.js:15 (process.<anonymous>) unhandledRejection catched: Promise {
  <rejected> Error: EAFNOSUPPORT, Address family not supported by protocol
      at new Hci (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/hci.js:74:18)
      at new NobleBindings (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:25:15)
      at Object.<anonymous> (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:546:18)
      at Module._compile (internal/modules/cjs/loader.js:1085:14)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module._load (internal/modules/cjs/loader.js:790:12)
      at Module.require (internal/modules/cjs/loader.js:974:19)
      at require (internal/modules/cjs/helpers.js:101:18)
      at module.exports (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/resolve-bindings.js:13:12)
      at Object.<anonymous> (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/index.js:2:49)
      at Module._compile (internal/modules/cjs/loader.js:1085:14)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module._load (internal/modules/cjs/loader.js:790:12)
      at Module.require (internal/modules/cjs/loader.js:974:19)
      at require (internal/modules/cjs/helpers.js:101:18)
      at BluetoothManager.start (/home/einstein/gladys/server/services/bluetooth/lib/commands/bluetooth.start.js:16:20)
      at Object.start (/home/einstein/gladys/server/services/bluetooth/index.js:16:22)
      at Service.start (/home/einstein/gladys/server/lib/service/service.start.js:33:21) {
    errno: 97,
    code: 'EAFNOSUPPORT',
    syscall: 'socket'
  }
}
2022-03-15T14:33:45+0100 <error> index.js:16 (process.<anonymous>) Error: EAFNOSUPPORT, Address family not supported by protocol
    at new Hci (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/hci.js:74:18)
    at new NobleBindings (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:25:15)
    at Object.<anonymous> (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:546:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at module.exports (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/lib/resolve-bindings.js:13:12)
    at Object.<anonymous> (/home/einstein/gladys/server/services/bluetooth/node_modules/@abandonware/noble/index.js:2:49)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at BluetoothManager.start (/home/einstein/gladys/server/services/bluetooth/lib/commands/bluetooth.start.js:16:20)
    at Object.start (/home/einstein/gladys/server/services/bluetooth/index.js:16:22)
    at Service.start (/home/einstein/gladys/server/lib/service/service.start.js:33:21) {
  errno: 97,
  code: 'EAFNOSUPPORT',
  syscall: 'socket'
}
2022-03-15T14:33:46+0100 <info> index.js:14 (Object.start) starting GoogleActions service
2022-03-15T14:33:46+0100 <log> index.js:16 (Object.start) Starting Zigbee2mqtt service
2022-03-15T14:33:46+0100 <warn> service.start.js:44 (Service.start) Unable to start service zigbee2mqtt PlatformNotCompatible [Error]: SYSTEM_NOT_RUNNING_DOCKER
    at Zigbee2mqttManager.init (/home/einstein/gladys/server/services/zigbee2mqtt/lib/init.js:15:11)
    at async Object.start (/home/einstein/gladys/server/services/zigbee2mqtt/index.js:17:5)
    at async Service.start (/home/einstein/gladys/server/lib/service/service.start.js:33:7)
2022-03-15T14:33:46+0100 <info> index.js:18 (Object.start) Starting TP-Link service
2022-03-15T14:33:47+0100 <info> index.js:17 (Object.start) Starting eWeLink service

And when I do on the nav: localhost:1443 I have: « cannot Get / »
For the client it starts well, but menu integration: does not find mqtt so zigbee, but also not bluetooth even though the phone is equipped with it…
There is docker desktop on windows but I don’t see anything related to docker in wsl/ubuntu is this normal?

This « problem » seems normal to me. I don’t think Bluetooth is available in WSL (I don’t know much about Windows, but I get the same messages when I run Gladys in a VM).

Unless you want to develop Bluetooth integration, it’s not necessarily a problem, unless it causes Gladys to crash, but I don’t think that’s the case here?

It’s http://localhost:1444/ for the frontend, not 1443.

Exactly, I have the same thing in native Linux (laptop with incompatible Bluetooth) and it doesn’t actually interfere with the startup.

I’m deleting my previous message to avoid confusing the discussion. (I didn’t notice the Bluetooth)

The problem is indeed on the server: localhost:1443 as mentioned in the online help and I have « cannot get » on the frontend on 1444 I have the classic Gladys screen but the integration menu is not great…

This is not an issue, the server does not expose a route on the « / »

So, according to you, can’t we do dev or test on Gladys with a Windows 11 laptop with WSL?

If we can be very well :slight_smile:

I admit that I can’t understand what’s wrong with you, everything is fine from what you tell me.

What kind of development or testing can be done if we cannot use Bluetooth or MQTT? This reduces the range of possibilities. Developing or testing on an incomplete platform, there may be gaps in the mesh.

If I regularly use the wsl env, however, it’s a bit annoying sometimes in terms of networking.

To bypass Windows, I launch a server on Windows and a browser in wsl.

For those who have the equipment, we’re not going to force everyone to buy a Bluetooth dongle, right?

And I would add, what is your goal with the development environment? Because it’s not really made for testing (we have Docker images for that).

You can use MQTT with a custom Mosquitto server running locally, but for the « launch a container via Docker » part, I don’t think it will work under WSL.

You can develop the Gladys interface (it remains the bulk of the work, working on the interface), but indeed the « physical hardware » part will not be ideal.

Gladys remains a software designed for a Linux environment, so developing in another environment will inevitably be different and incomplete. For real testing, indeed, there is no choice but to be on Linux.

After experience, 90% of all development is done largely without having a complete environment (working on the interface, API routes, unit tests, etc… there is no need to have working hardware).

For my part, I develop Gladys mainly on MacOS, and I do my real tests on Linux. Either in a virtual machine for everything related to Zigbee2mqtt/MQTT, or on a Pi when testing with hardware.

I have several development tracks, but two main ones:

1/ I have a chicken coop 50m from my house that I would like to automate. There is electricity but no Wi-Fi… The idea is to manage lighting, opening the coop door, and a camera. I have Wi-Fi and Ethernet cameras (without software) to repurpose. The idea would be to hybridize CPL and Wi-Fi or RF to manage this via Gladys.

2/ Retrieve data from my weather station directly locally without going through the Wunderground API (depending on a third party without guarantee for my own data bothers me)

3/ And I’m not even talking about the automation of my garden (irrigation, …), my mini wind turbine…

On the Linux aspect, I agree with you. I am very open source, but to avoid « hybrid » hosting despite my 17 PCs (only 3 under W, the rest under Linux distros), I unfortunately only have a W11 laptop available right now for computer development, hence the WSL solution to have Linux anyway.

But if my concerns as a retired computer scientist (over 40 years of computer experience at different levels) seem too utopian and disturbing to you and not in line with your vision of Gladys, I can continue on my own.

Most Gladys developers, in my opinion (some on Mac, some on WSL), don’t develop under Linux, so this setup isn’t utopian.

After that, you have to be aware of the limitations and have a Linux test environment for real tests.

But from what I read in your message:

I don’t see anything that wouldn’t work under WSL :slight_smile:

Pierre-gilles,
you reassure me by saying that!
but I remain skeptical, looking at the client’s integration tab, apart from MQTT, Zigbee and Bluetooth, I only see names of « proprietary » module brands. Given my idea of doing DIY with ‹ recovered › sensors and objects based on Arduino, RF, CPL, etc., I was convinced that the transition to MQTT, Zigbee, BT and even « NodeRed » was almost essential to interface this with Gladys.
As much as in these projects, especially in the garden, there is management of a drone and a robot (like a Mars rover), and then there will be my lab and my workshop…
but for a start, to get my hands on it, I will focus on my shutters which are automated in RF 433MHz (unknown brand)
playable or not in your opinion?

and I must say that by visualizing your broadcast on Guilhem and his PV panels, it gives me ideas

Everything is possible :slight_smile: :blush:

However, from what you’re telling me, I don’t quite understand why you would need a development environment ^^

If you just want to send new data to your 433Mhz Gladys instance, Arduino, etc… just use the MQTT integration or Node-RED