How to connect to Nibe heat pump without the cloud

Hello, please could someone confirm that SMOS40 unit (AMS 10-12 heat pump) shows Compressor frequency via MODBUS TCP? Mine doesn´t. It shows just: [sensor.nibe_f2040_compressor_freq] unavailable. Other sensors run fine. Thank you.
In my yaml there is sensor:

    - name: nibe_f2040_compressor_freq
      unit_of_measurement: hz
      slave: 1
      address: 1803

Are you sure that SMO20 is compatible?
This model doesn’t appear in the official publication

Hi,
I have a SMO20. What kind of test you did? I can see the menu 7.x.x from de device.

thanks

Hi @elupus,
First of all thank you very much for developing this integration!
I tried to use it with my S320, however it is not working.
There is also no error in the HA-logs.

However I do not get any value from my S320.
If you use direct modus command via HA modbus I am able to read the registers.
Do you have any idea, what I am doing wrong?
Thanks a lot for your support!

There is very likely something in your logs.

Or en error displayed in the dialog.

image

Restarted HA and this the the log after 5 minutes.
That is the strange thing that I am not able to find any error :frowning:

2022-12-23 19:28:38.674 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.675 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration dwd_weather which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.677 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration waste_collection_schedule which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.678 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration openwbmqtt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.679 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration rewe which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.680 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration nibe which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.680 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration o365 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.682 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration ics_calendar which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.683 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration fronius_inverter which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:38.684 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration audiconnect which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2022-12-23 19:28:53.219 WARNING (MainThread) [xknx.log] Could not sync group address ‘1/2/94’ (Zisterne Füllstand Liter - Value)

2022-12-23 19:29:02.764 WARNING (MainThread) [xknx.log] Error: KNX bus did not respond in time (2.0 secs) to GroupValueRead request for: 2/2/94

2022-12-23 19:29:02.766 WARNING (MainThread) [xknx.log] Could not sync group address ‘2/2/94’ (Zisterne Füllstand % - Value)

2022-12-23 19:29:49.198 WARNING (SyncWorker_4) [custom_components.ics_calendar.calendar] Trying to decode strm!

@T_A For me all the entities were disabled by default, so I had to enable the entities I wanted to use.

I was just going to say. They are disabled by default. They are just too many of them.

Thanks for your feedback but I already activated some sensors. However I do not get any data :frowning:

If I enable the “Energy meter” entity it breaks all other entities. Maybe you have a similar issue. Try disabling all entities and enable only one, wait for a minute or two, and see if that works.

Here are a few that works for me:

THANK YOU!!!
It is working, now. :slight_smile: !

Can you let me know all sensors are working for you?

Are you using a sensor integration which can force add. hot water or rise the heating?
Looking forward to integrate this into a flow for PV power usage.

Hi all,

Love the work you’ve been doing on this integration.
Today I’ve build myself a nibegw using a pi zer 2 w a waveshare RS485/CAN hat and a wide input shim.

Wired it up to the heatpump, started the nibegw after compiling it, updated my heatpump to latest version (VMM320 btw) enable Modbus in system settings menu.
But my pump keeps going in to error so I guess something is still wrong.

I’ve used this command to start the gw instance: ./nibegw -vvv -d /dev/ttyS0 -a 10.10.10.10
(ran it as the pi user btw, I’ve added the pi user to the dialout group, not sure if needed though)
Output extract can be found below.

NibeGW version:                    1.23
Verbose level:                     3
Test mode:                         FALSE
Serial port:                       /dev/ttyS0
Flow control:                      HW
remote UDP address:                10.10.10.10:9999
server UDP address for read cmds:  10000
server UDP address for write cmds: 10001
RS-485 address to listen:          0x20
Send all messages by UDP:          FALSE
Send acknowledge:                  TRUE
Send acknowledge to all addresses: FALSE
Open serial port: /dev/ttyS0
Initialize UDP server
Initialize UDP server

2022.12.24 22:31:37:391173: EF
2022.12.24 22:31:37:391523: BF
2022.12.24 22:31:37:391612: EF
2022.12.24 22:31:37:391690: FF
2022.12.24 22:31:37:391768: 5C 54 BF 2B FE 06 5C BC 8E 3E 31 67 97 5C BC 8E 3E 31 67 97 5C BC 8E 3E 31 67 97 5C 54 7D 4B 7A 5C 34 79 4B 7A 5C 34 79 4B 7A 5C                                                                                  54 3D 6B 6A 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 34 19 EB FF FF 10 30 FF FF 10 FF FF 4B FF FF 20 2B FF FF 6B AB FF A9 A5 8B BA FF 00 E8 00 A8 00 A8 00 A8 00 A8                                                                                  00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 FD 5C 34 19 EB FF 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8                                                                                  00 A8 00 A8 00 A8 00 A8 00 A8 FD 5C 54 1D EB FF FF 08 18 F5 55 FF FF 10 30 FF 96 60 00 E8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8                                                                                  00
2022.12.24 22:31:37:392167: A8
2022.12.24 22:31:37:392270: 00
2022.12.24 22:31:37:392348: A8
2022.12.24 22:31:37:392424: 00
2022.12.24 22:31:37:392500: A8
2022.12.24 22:31:37:392576: 00
2022.12.24 22:31:37:392672: A8
2022.12.24 22:31:37:392749: FD
2022.12.24 22:31:37:392824: 5C 54 7D 4B 7A 5C 34 79 EF FF 06 5C FB D9 5D 55 5D 55 55 D5 5D 9B 19 D7 AA 57 B6 93 B6 26 66 FF 5C 54 31 06 DA D7 A2 F1 EB B5 F8                                                                                  79 F2 DF D8 3C 7E 20 00 A8 BD FF 5C BC 6E 66 27 1B 95 FA BF 71 B5 7C 7E 5E 1F 75 1D 75 35 55 55 54 56 75 FF 5C 34 AF 29 6F 5C 34 79 4B 7A 5C 34 79 5C 54 BF                                                                                  2B FE 06 5C 54 7D 4B 7A 5C 54 7D 4B 7A 5C 34 79 4B 7A 5C 34 39 6B 6A 5C 54 3D 6B 6A 5C 54 3D 6B 6A (calc/recv checksum 16/6A = ERROR)

2022.12.24 22:33:22:966059: 5C 34 79 4B FE FF 5C 34 79 4B 7A 5C 34 79 4B 7A 5C 34 39 6B DE FF 5C 54 3D 6B 6A 5C 34 39 6B 6A 5C 54 7D 4B 7A 5C 34 79 4B 7A 5C                                                                                  34 79 4B 7A 5C 34 39 6B DE FF 5C 34 39 6B 6A 5C 54 3D 6B 6A 5C 34 19 4B FF 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 E8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00                                                                                  A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 FD 5C 54 1D EB FF FF 08 18 F5 55 FF FF 10 30 FF 96 60 00 A8 00 E8 00 A8 00 E8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00                                                                                  A8 00 A8 00 A8 00 A8 00 A8 00 A8 FF 5C 34 19 EB FF FF 10 30 FF FF 10 FF FF 4B FF FF 20 2B FF FF 6B AB FF A9 A5 8B BA FF 00 E8 00 A8 00 A8 00 A8 00 A8 00 A8                                                                                  00
2022.12.24 22:33:22:966465: A8
2022.12.24 22:33:22:966572: 00
2022.12.24 22:33:22:966651: A8
2022.12.24 22:33:22:966778: 00
2022.12.24 22:33:22:966860: A8
2022.12.24 22:33:22:966997: 00
2022.12.24 22:33:22:967075: A8
2022.12.24 22:33:22:967152: 00
2022.12.24 22:33:22:967226: A8
2022.12.24 22:33:22:967340: 00
2022.12.24 22:33:22:967411: A8
2022.12.24 22:33:22:967488: 00
2022.12.24 22:33:22:967598: A8
2022.12.24 22:33:22:967675: FD
2022.12.24 22:33:22:967744: 5C 54 7D 4B 7A 5C 34 79 4B FE FF 5C 54 7D 4B 7A 5C 54 3D 6B 6A 5C 34 39 6B 6A 5C 54 3D 6B 6A 5C 34 79 4B 7A 5C 34 79 C5 0A D6 5C                                                                                  34 39 6B 6A 5C 34 39 6B 6A 5C 34 79 5C 54 9F 7C 11 D4 FD 5C 54 C6 27 6C 76 FF 5C 54 7D 4B 7A 5C 54 7D 4B 7A 5C 34 79 FF FB 5C 34 79 4B 7A 5C 34 79 4B FE FF                                                                                  5C 34 79 4B 7A 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 34 39 6B DE FF 5C 34 79 4B 7A 5C 34 79 5C 34 79 4B (calc/recv checksum C4/4B = ERROR)

2022.12.24 22:40:03:860643: 7A
2022.12.24 22:40:03:860744: 5C 34 79 4B 7A 5C 34 79 4B FE FF 5C 54 3D 6B 6A 5C 34 39 6B 6A 5C 54 3D 6B 6A 5C 54 7D 4B 7A 5C 34 79 4B 7A 5C 34 79 4B FE FF 5C                                                                                  34 39 6B 6A 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 54 7D 4B 7A 5C 34 79 4B 7A 5C 34 79 4B 7A 5C 54 3D 6B 6A 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 34 79 4B 7A 5C 34 79                                                                                  4B 7A 5C 34 79 4B FE FF 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 34 39 6B 6A 5C 54 1D EB FF FF 08 18 F5 55 (calc/recv checksum 78/55 = ERROR)

2022.12.24 22:40:03:861058: FF
2022.12.24 22:40:03:861131: FF
2022.12.24 22:40:03:861868: 10
2022.12.24 22:40:03:862644: 30
2022.12.24 22:40:03:863556: FF
2022.12.24 22:40:03:864305: 96

Anyone have any idea what the issue could be?
I’ve tried creating a log.set file with only a few params to test but same issue :frowning:
The -a param is the IP of homeassistant I guess? Also, not so sure that the waveshare RS485 hat needs some special config apart from adding some settings in the config.txt as per their wiki (RS485 CAN HAT - Waveshare Wiki)

nvm, I think I’ve fixed this. Merry Christmas to me (and my heatpump?) :sweat_smile:

Seriously though, if anyone has this issue:
I’ve installed pyserial.

sudo apt install python3-serial

Ran the waveshare HEX receive script to test (Do set the baud to 9600 though and rename the file as they messed up spacing). (RS485 CAN HAT - Waveshare Wiki)

wget https://www.waveshare.com/w/upload/0/00/RS485-CAN-HAT-For-Hex.zip
unzip RS485-CAN-HAT-For-Hex.zip
sudo chmod 777 RS485-CAN-HAT-For-Hex.zip
cd RS485-CAN-HAT-For-Hex
#Receive Hex
sudo python3 RS485-CAN-HAT-receive-hex.py

This received the data for me, after restarting the nibegw all was working!

So I guess… something with the installation of pyserial fixed this issue?? not to sure though…

Merry Christmas for all!

@elupus First - thanks a lot for creating this integration.

I’ve not seen anyone commenting or writing about the serial modbus connection yet. I can confirm that my F1245 works using the serial:// URL and connected to the USB port on my RPi4. The connection is USB → RS485 dongle → Nibe MODBUS 40 shunt → F1245 heat pump.

One thing I would like to ask - the HA entities are currently logging/updating values only every 5 minutes. In between everything shows as “Unavailable” on the dashboard. Is there a way to set the update interval to a shorter period? I don’t see anything about this in the documentation and could not figure it out from a quick look in to the source code. Everything I read is in the LOG.SET file on the heat pump and I can read it in short intervals through my Python test script using @yozik04 's nibe library.

They should not go unavailable inbetween. Do you have some errors in your logs?

Ps. I think you might be the first person running an actual modbus40 unit with this integration.

Thanks for such a quick reply!
No there are no logs / errors regarding the integration.

Well, if I’m the first I’m also ready to help with debugging and stuff.

EDIT: Looking once more at the logs… There actually came up this one:

2022-12-26 15:10:23.494 ERROR (MainThread) [homeassistant.components.nibe_heatpump] Error fetching Nibe Heat Pump data: Failed to update: Timeout waiting for read response for bt2-supply-temp-s1-40008

Just quickly coming back to this in case it helps someone else.
This didn’t actually fix the issue. It temporarily resolved it by settings some params on the serial port.
After rebooting the pi it was broken again.

I wouldn’t call myself a programmer by any means… so I might be wrong here.
But it turns out the issue is related to running the serial port in canonical vs non-canonical mode.

Freshly booting the pi sets these params on /dev/ttyS0:

user@rpizero2w:~ $ stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

Running the nibegw (nibegw -d /dev/ttyS0 -a 10.10.10.10 -vv) makes this:

user@rpizero2w:~ $ stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 1;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

Running the waveshare read python script turns this to:

user@rpizero2w:~ stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

Running the nibegw again after this makes it work (since settings are changed):

user@rpizero2w:~ stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 1;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

The hardware-control param (crtscts) is settable through the nibegw script, so I didn’t touch that.
I disabled all the other params in the original C code to match the last state… and guess what… rebooting the pi and starting my modified nibegw (via systemctl) just works.

Strange that no one else has this issue with the product? (I’m rocking rpi zero 2w rev. 1, Waveshare RS485 CAN hat) Should I create a pull request for this or is there another explanation? (@elupus)

For those wondering, replace the initSerialPort (line 95-134) with this:

int initSerialPort(int fd, int hwflowctrl)
{
	struct termios options;
	
	// Get the current options for the port...
	
	tcgetattr(fd, &options);
	
	// Set the baud rates
	cfsetispeed(&options, B9600);
	cfsetospeed(&options, B9600);
	
	// Enable the receiver and set local mode...
	options.c_cflag |= (CLOCAL | CREAD);
	
	// 8 data bits, no parity, 1 stop bit
	options.c_cflag &= ~PARENB;
	options.c_cflag &= ~CSTOPB;
	options.c_cflag &= ~CSIZE;
	options.c_cflag |= CS8;
	
	if (hwflowctrl)
		options.c_cflag |= CRTSCTS;		// Enable hardware flow control
	else
		options.c_cflag &= ~CRTSCTS;	// Disable hardware flow control
	
	// Flow control
	options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL );
	
	// Local flags
	options.c_lflag &= ~(ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHONL | ECHOCTL | ECHOKE );
	
	options.c_oflag &= ~(OPOST | ONLCR);
	
	options.c_cc[VMIN] = 1;				// Min character to be read
	options.c_cc[VTIME] = 1;			// Time to wait for data (tenth of seconds)
	
	// Set the new options
	if (tcsetattr(fd, TCSANOW, &options) < 0 )
	{
		return -1;
	}
	
	return 0;
}

Extra info: (removed some as I cannot post more then 2 links yet)

https://www.gnu.org/software/libc/manual/html_node/Local-Modes.html