wimleers / homebridge-sma-home-manager

SMA Home Manager & Inverter plug-in for Homebridge
GNU General Public License v2.0
10 stars 2 forks source link

[Bug] Bridge restarting, SHM, SBS, STP 15000TL not available #21

Open funx1 opened 6 months ago

funx1 commented 6 months ago

Paste of Logs:

[12/02/2024, 11:01:10] [homebridge-sma-home-manager] Restarting Process...
[12/02/2024, 11:01:12] [homebridge-sma-home-manager] Launched child bridge with PID 20923
[12/02/2024, 11:01:13] Registering platform 'homebridge-sma-home-manager.SMAHomeManager'
[12/02/2024, 11:01:13] [homebridge-sma-home-manager] Loaded homebridge-sma-home-manager v1.1.8 child bridge successfully
[12/02/2024, 11:01:13] Loaded 0 cached accessories from cachedAccessories.0E925CDAD228.
[12/02/2024, 11:01:13] [homebridge-sma-home-manager] Found inverter SMA30120xxxx at SMA3012xxx.local with IPv4 address 192.168.179.182.
[12/02/2024, 11:01:14] [homebridge-sma-home-manager] Discovered SMA inverter: no
[12/02/2024, 11:01:14] [homebridge-sma-home-manager] Discovered SMA energy manager: { Model: 372, SerialNumber: 30118xxxx, FirmwareRevision: '2.13.6.R' }
/var/lib/homebridge/node_modules/homebridge-sma-home-manager/index.js:402
                                const deviceClassId = data.buffer.slice(0, 4).readUInt32BE();
                               ^
TypeError: Cannot read properties of undefined (reading 'buffer')
    at SMAHomeManager.<anonymous> (/var/lib/homebridge/node_modules/homebridge-sma-home-manager/index.js:402:32)
    at TcpPort.<anonymous> (/var/lib/homebridge/node_modules/homebridge-sma-home-manager/node_modules/modbus-serial/index.js:340:37)
    at TcpPort.emit (node:events:517:28)
    at Socket.<anonymous> (/var/lib/homebridge/node_modules/homebridge-sma-home-manager/node_modules/modbus-serial/ports/tcpport.js:77:20)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Socket.Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[12/02/2024, 11:01:14] [homebridge-sma-home-manager] Child bridge process ended
[12/02/2024, 11:01:14] [homebridge-sma-home-manager] Process Ended. Code: 1, Signal: null
[12/02/2024, 11:01:18] [homebridge-sma-home-manager] Restarting child bridge...
[12/02/2024, 11:01:21] [homebridge-sma-home-manager] Restarting Process...
[12/02/2024, 11:01:23] [homebridge-sma-home-manager] Launched child bridge with PID 20937
[12/02/2024, 11:01:23] Registering platform 'homebridge-sma-home-manager.SMAHomeManager'
[12/02/2024, 11:01:24] [homebridge-sma-home-manager] Loaded homebridge-sma-home-manager v1.1.8 child bridge successfully
[12/02/2024, 11:01:24] Loaded 0 cached accessories from cachedAccessories.0E925CDAD228.
[12/02/2024, 11:01:24] [homebridge-sma-home-manager] Found inverter SMA30120xxxxx at SMA30120xxxxx.local with IPv4 address 192.168.179.182.
[12/02/2024, 11:01:25] [homebridge-sma-home-manager] Discovered SMA inverter: no
[12/02/2024, 11:01:25] [homebridge-sma-home-manager] Discovered SMA energy manager: { Model: 372, SerialNumber: 301184xxxx, FirmwareRevision: '2.13.6.R' }
[12/02/2024, 11:01:25] [homebridge-sma-home-manager] Child bridge process ended
[12/02/2024, 11:01:25] [homebridge-sma-home-manager] Process Ended. Code: 1, Signal: null
[12/02/2024, 11:01:32] [homebridge-sma-home-manager] Restarting Process...
[12/02/2024, 11:01:34] [homebridge-sma-home-manager] Launched child bridge with PID 20951
[12/02/2024, 11:01:34] [homebridge-sma-home-manager] Loaded homebridge-sma-home-manager v1.1.8 child bridge successfully
[12/02/2024, 11:01:35] [homebridge-sma-home-manager] Found inverter SMA30120xxxxx at SMA3012001984.local with IPv4 address 192.168.179.182.
[12/02/2024, 11:01:36] [homebridge-sma-home-manager] Discovered SMA inverter: no
[12/02/2024, 11:01:36] [homebridge-sma-home-manager] Discovered SMA energy manager: { Model: 372, SerialNumber: 301184xxxx, FirmwareRevision: '2.13.6.R' }
[12/02/2024, 11:01:36] [homebridge-sma-home-manager] Child bridge process ended
[12/02/2024, 11:01:36] [homebridge-sma-home-manager] Process Ended. Code: 1, Signal: null
[12/02/2024, 11:01:43] [homebridge-sma-home-manager] Restarting Process...
[12/02/2024, 11:01:45] [homebridge-sma-home-manager] Launched child bridge with PID 20965
[12/02/2024, 11:01:45] [homebridge-sma-home-manager] Loaded homebridge-sma-home-manager v1.1.8 child bridge successfully
[12/02/2024, 11:01:46] [homebridge-sma-home-manager] Found inverter SMA30120xxxxx at SMA30120xxxx.local with IPv4 address 192.168.179.182.
[12/02/2024, 11:01:47] [homebridge-sma-home-manager] Discovered SMA inverter: no
[12/02/2024, 11:01:47] [homebridge-sma-home-manager] Discovered SMA energy manager: { Model: 372, SerialNumber: 30118xxxx, FirmwareRevision: '2.13.6.R' }```

**Config:**
<!-- Paste relevant output between the two ``` lines below -->
<!-- Remove any sensitive information, passwords, etc. -->

```json

Screenshots:

Inverter: SHM

Homebridge Environment: local network

funx1 commented 6 months ago

Some ideas?

wimleers commented 6 months ago
/var/lib/homebridge/node_modules/homebridge-sma-home-manager/index.js:402
                                const deviceClassId = data.buffer.slice(0, 4).readUInt32BE();
                               ^
TypeError: Cannot read properties of undefined (reading 'buffer')

☝️ Looking at the relevant code:

            // Read device class (U32, ENUM).
            client.readHoldingRegisters(30051, 4, function(err, data) {
                const deviceClassId = data.buffer.slice(0, 4).readUInt32BE();
                deviceType = data.buffer.slice(4, 8).readUInt32BE();
                deviceClass = SMA_DEVICE_CLASSES.get(deviceClassId) || `unknown ${deviceClassId}`;
                registerInverterDiscoveryIfComplete();
            }.bind(this));

That's blindly reading data and is ignoring err altogether 😬 This is one of the last remaining patterns of code remaining of the original codebase that I forked from (https://github.com/codyc1515/homebridge-sma-inverter).

Question: Modbus TCP/IP is enabled?

funx1 commented 6 months ago

TCP is active on the STP and SBS. Actually I can access the SBS from the HA SMA implementation but not the STP. But I was able to access values over iobroker and modus.

wimleers commented 5 months ago

Actually I can access the SBS from the HA SMA implementation

Last time I looked, the Home Assistant integration was scraping the inverter's web UI 😨

But I was able to access values over iobroker and modus.

How does iobroker get the data? And what is "modus"?

funx1 commented 5 months ago

I give up on this. Using now HA with modbus to read out values. Integrations I tried did not work. Previously with iobroker I was using modbus too. After switching to homebridge I lost these values. But I will start reading them with modbus again.