Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Please could you please include Values from the SMA Energy Meter for people without the Home Manager? #12

Open
silvertristan opened this issue Mar 27, 2023 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@silvertristan
Copy link

I don't have a Home Manager as I don't really require it.

As the Old SMA plugin had I can see my current PV generation and Daily Yield. I would love to have the information like what my house is currently using, what's being fed into the grid plus daily yield and generation. I understand your plugin is to be able to control your homes energy usage using automations via the home app. For someone like me being able to see the value I have request is also a great help. Doing it all in the home app would be great rather than having to use the clunky SMA Energy app.

Inverter:

  • Model: SB6.0-1AV-41 487
@silvertristan silvertristan added the enhancement New feature or request label Mar 27, 2023
@wimleers
Copy link
Owner

Based on the title, it sounds like you have an SMA Energy Meter in addition to your inverter. Is that right?

If so: that should work out of the box, at least according to SMA's own documentation at https://developer.sma.de/fileadmin/content/global/Partner/Documents/SMA_Labs/EMETER-Protokoll-TI-en-10.pdf.

But in your comment you only listed an inverter?

@silvertristan
Copy link
Author

Hi,
Sorry. First time ever doing something like this with a Homebridge plugin. My apologies if I sound dumb.

Yes, I have the SMA Energy Meter with the Sunnyboy 6 inverter.

I have enabled the modbus and can confirm this as it works with the old SMA plugin.

When I enable your plugin i get this in the log over and over again and I have to disable the plugin to get homebridge working again:
3/6/2023, 12:58:12 PM] [homebridge-sma-home-manager] Discovered SMA energy manager: no [3/6/2023, 12:58:13 PM] [homebridge-sma-home-manager] Discovered SMA inverter: { SerialNumber: 3007638487, FirmwareRevision: '1.1.85.R' }

Thanks for replying.
Tristan

@wimleers
Copy link
Owner

wimleers commented Mar 27, 2023

Could you post a photo of your SMA Energy Meter? 🙏

P.S.: you definitely don't sound dumb! This can get pretty confusing 😊

@silvertristan
Copy link
Author

IMG_6487

@wimleers
Copy link
Owner

That's odd, based on the photo and SMA's documentation, this should work just fine! 😬

Could you please:

  • post the firmware version
  • post a screenshot of your SMA Energy Manager's data appearing in Sunny Portal
  • install https://apps.apple.com/be/app/discovery-dns-sd-browser/id305441017?l=nl and post a screenshot of what you see after tapping "World Wide Web HTTP"
  • describe the network path between your SMA Energy Manager and device that Homebridge is running on (for example for me that's SMA Energy Manager → switch → router → switch → Homebridge)

@wimleers wimleers self-assigned this Mar 28, 2023
@wimleers
Copy link
Owner

Can you please update to https://github.com/wimleers/homebridge-sma-home-manager/releases/tag/1.1.3 and share the logged DeviceType? Thanks 🙏

@silvertristan
Copy link
Author

I'm at F1 in Melbourne all weekend. When I'm back on Monday I'll get on it. Thanks again.

@silvertristan
Copy link
Author

Hi,

Just to clarify I don't have an Energy Manager. I have a Energy Meter.

This is what I'm currently getting in the Homebridge log once updated:
}
[11/04/2023, 5:47:16 pm] [homebridge-sma-home-manager] Discovered SMA energy manager: no
[11/04/2023, 5:47:17 pm] [homebridge-sma-home-manager] Discovered SMA inverter: {
DeviceClass: 'solar inverter',
DeviceType: 9405,
SerialNumber: 3007638487,
FirmwareRevision: 'unknown'
}

Inverter Firmware version: 4.0.75.R
Devicetype: I can't see it anywhere or I don't know what you mean.
Network Path: SMA Energy Meter>(Ethernet)Sunnyboy Inverter>(WiFI)Router/Modem>(WiFi)Homebridge
Requested Screenshots below:
Screenshot 2023-04-11 at 5 54 06 pm
Screenshot 2023-04-11 at 5 53 56 pm
Screenshot 2023-04-11 at 5 51 47 pm

Thanks again for looking into this.
Cheers Tristan.

@wimleers
Copy link
Owner

That all looks fine 😬 (Very similar to what I see!)

Your solar inverter is also of the exact same series as mine — you just have the 6 kW one, I have the 5 kW one.

Could you please:

  1. Can you send me a screenshot of https://169.254.12.3/#/devicemanagement or https://192.168.0.16/#/devicemanagement? (You may need to log in first.)
  2. describe the network path between your SMA Energy Manager and device that Homebridge is running on (for example for me that's SMA Energy Manager → switch → router → switch → Homebridge)

(I still suspect that this is a pure networking problem. i.e. that it's impossible for the computer on which you have Homebridge running to receive multicast packets from the Energy Meter.)

@silvertristan
Copy link
Author

image

Just to note and maybe it got missed in previous conversations just so we're not talking about two different things. I only have the inverter and energy meter. No energy manager. Hence why I just wanted to see valves and not controller the energy use like your plugin offers. With the old SMA plug-in I could see current generation and daily yield. With your plug-in you get a lot more info. I would also like to see current usage in addition to the generation and yield.

If we can't get it worked out I don't want to waste your time. You've done a great job with this plug-in and I'm sure you've got bigger fish to fry.

EnergyMeter(Ethernet)>Inverter(wifi)>router/modem(wifi)>homebridge(wifi)

Thanks again.

@wimleers
Copy link
Owner

wimleers commented May 28, 2023

That all looks fine 👍

I only have the inverter and energy meter.

Yep!

Hence why I just wanted to see valves and not controller the energy use like your plugin offers.

Well that's the thing: the Home Manager and Energy Meter should be identical as far as this Homebridge plugin is concerned! The only difference is that the Home Manager can independently send signals to devices. For example, for me it controls my heatpump.
Either way, you should be able to get the same exact data, and create the same exact automations in Apple HomeKit.

EnergyMeter(Ethernet)>Inverter(wifi)>router/modem(wifi)>homebridge(wifi)

Do you have a single router/modem, no other WiFi access points?

@silvertristan
Copy link
Author

Just the one router/modem and that is the only access point.

The modem does have 2 SSID's for 2.4Ghz and 5Ghz but both the inverter and homebridge are on 2.4.

@wimleers
Copy link
Owner

That's for sure puzzling 🤔

It's a mystery to me why your homebridge instance wouldn't receive the multicast packets that your energy meter is broadcasting via IP multicast…

After some more pondering, I thought of one way this could still not work for you: is it possible that the device running Homebridge has:

  • multiple connections to the the network? (one or more of Ethernet and/or one or more of WiFi)
  • an IPv6 address, not IPv4?

If you're up for it: install Wireshark and observe! 😄

@silvertristan
Copy link
Author

silvertristan commented May 31, 2023

Hey,

Checked it is IPv4 and no multiple connections to network. I'll have to install wireshark to see what's happening.

Thanks,

@wimleers
Copy link
Owner

wimleers commented Jun 1, 2023

Okay. To clarify: if there were multiple connections, it would have been possible that this plugin was not correctly listening for multicast on all network connections. But if there's only a single one, I don't see how that's possible.

See

_listenToHomeManager: function() {
this.socket = dgram.createSocket({type: 'udp4', reuseAddr: true});
this.socket.on('error', function(err) {
this.log.error("Listening to SMA Home Manager failed, will attempt to reconnect. Error:", err);
this.importRealtime.getCharacteristic(Characteristic.On).updateValue(false);
this.exportRealtime.getCharacteristic(Characteristic.On).updateValue(false);
this.importService.getCharacteristic(Characteristic.On).updateValue(false);
this.exportService.getCharacteristic(Characteristic.On).updateValue(false);
this.clearInterval(this.multicastMembershipIntervalId);
this.socket.close(function() {
setTimeout(this._listenToHomeManager.bind(this), 10 * 1000)
}.bind(this));
}.bind(this));
this.socket.on('listening', function() {
this.socket.addMembership(this.homeManagerAddress);
this.multicastMembershipIntervalId = setInterval(this._keepMembershipActive.bind(this), 120*1000);
}.bind(this));
this.socket.on('message', function(msg, rinfo) {
if (!this._isValidDatagram(msg)) {
return;
}
// When not yet launched, enable the launch to happen by only parsing the
// datagram, this will populate this.discovered.energyManager.
if (!this.launched) {
this._parseDatagram(msg, rinfo);
return;
}
// Read the live production from the inverter, to minimize the time offset
// relative to the received energy manager datagram (S32, FIX0: 0 decimals).
const before = performance.now();
client.readHoldingRegisters(30775, 2).then((data) => {
return data.buffer.equals(SMA_MODBUS_S32_NAN_VALUE) ? 0 : data.buffer.readInt32BE();
})
.then((producedWatts) => {
const estimatedMsOffset = performance.now() - before;
const [timestamp, netWatts] = this._parseDatagram(msg, rinfo);
this._processMeasurement(producedWatts, netWatts, timestamp, estimatedMsOffset);
})
}.bind(this));
// Actually start listening.
this.socket.bind(this.homeManagerPort);
},
.

Actually, there's one thing you could try to do, change:

		this.socket.on('listening', function() {
			this.socket.addMembership(this.homeManagerAddress);
			this.multicastMembershipIntervalId = setInterval(this._keepMembershipActive.bind(this), 120*1000);
		}.bind(this));

to:

		this.socket.on('listening', function() {
			console.log('NOW LISTENING!');
			this.socket.addMembership(this.homeManagerAddress);
			this.multicastMembershipIntervalId = setInterval(this._keepMembershipActive.bind(this), 120*1000);
		}.bind(this));

to get a log entry to know for sure that the plugin actually started listening.

(But really, if it fails, then we should see Log entries generated by the this.socket.on('error' listener… 😬 )

P.S.: one thing I didn't ask you to try yet, is running Homebridge in debug mode. That will generate more log entries and maybe that contains a helpful hint!

@raimund-hdr
Copy link

If this issue is not resolved yet you may check the configuration of the energy meter. it is possible to change the multicast destinationthere . Maybe that has been changed. Sometimes installers change that to a unicast address of the inverter to overcome issues with powerline bridges which do not alway handle multicasts correctly (IGMP issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants