yozik04 / nibe

Library for communication with Nibe heatpumps.
GNU General Public License v3.0
47 stars 36 forks source link

S-model VVM325 #7

Closed latisen closed 2 years ago

latisen commented 2 years ago

Creating this thread to solve issues and make it work with the S-model VVM325

Regular manual: https://www.nibe.eu/assets/documents/14743/331115-1.pdf Modbus manual: https://www.nibe.eu/download/18.3db69dc1795e0d992c5722/1622634529178/Modbus%20S-series%20EN%20M12676EN-1.pdf

@yozik04 : Is this sufficient? I have a contact at NIBE technical department in sweden that I can probably get more information from :)

yozik04 commented 2 years ago

Hi @latisen. Yes, should be enough. You can start with just couple of coils to try. Here is example of one of the supported models I exported from Nibe Modbus https://github.com/yozik04/nibe/blob/master/nibe/data/vvm225_vvm320_vvm325.json You can skip entering name I will generate it from title and address later.

latisen commented 2 years ago

@yozik04: Just to make sure I understand the json. In my case, the first (40004) should instead be 1 ? As the ID in the PDF?

latisen commented 2 years ago

@yozik04 : Also, can I edit it locally when testing somehow?

yozik04 commented 2 years ago

I'd recommend developing on computer, not a RPI. You can install everything locally and run from there.

latisen commented 2 years ago

Was just thinking if the file is located locally on the Pi I can use the storage on there to change the json. Just a few posts to see if it works at all

yozik04 commented 2 years ago

It is definitely located somewhere. But it would not be easy to find the path. Somewhere in a docker container, python lib's installation path...

latisen commented 2 years ago

@yozik04 But then I have to make requests for you to accept to test? No superfamiliar with GIT and team work :)

latisen commented 2 years ago

@yozik04 : And since its located in another repo (nibe), do I have to reinstall the addon after each change to make sure it downloads the updated json file?

yozik04 commented 2 years ago

This is why I recommend to install everything on computer.

yozik04 commented 2 years ago

With PyCharm CE should be quite simple

latisen commented 2 years ago

Ok, Ill see what I can do. Not used to needing a complete development environment just to change stuff like this :) But Ill see what i can do.

latisen commented 2 years ago

@yozik04 : I have cloned the repo and copied your example from the nibe repo. just to test, I edited the VVM325 json file, and changed model to 325 in the code (democode). It only outputs

File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\nibe\heatpump.py", line 74, in get_coil_by_address raise CoilNotFoundException(f"Coil with address {address} not found") nibe.exceptions.CoilNotFoundException: Coil with address 30009 not found

Which indicated it cant find 30009 in the json, correct? I got this in the json:

"30009": { "title": "BT7 HW Top", "info": "Hot water top temperature, BT7", "unit": "\u00b0C", "size": "s16", "factor": 10, "name": "bt7-hw-top-30009"

also tried get_coil_by_name('bt7-hw-top-30009') which resulted in the same output, but saying it could not find the name.

yozik04 commented 2 years ago

You need to show the code.

yozik04 commented 2 years ago

You can use this site https://gist.github.com/

latisen commented 2 years ago

You need to show the code.

This: [`import asyncio import logging

from nibe.coil import Coil from nibe.connection.modbus import Modbus from nibe.heatpump import HeatPump, Model

logger = logging.getLogger("nibe").getChild(name)

def on_coil_update(coil: Coil): logger.debug(f"on_coil_update: {coil.name}: {coil.value}")

async def main(): heatpump = HeatPump(Model.VVM325) heatpump.initialize()

heatpump.subscribe(HeatPump.COIL_UPDATE_EVENT, on_coil_update)

connection = Modbus(heatpump=heatpump, url="tcp://10.0.1.15:502", slave_id=1)

coil = heatpump.get_coil_by_address('30009')
await connection.read_coil(coil)

logger.debug(f"main: {coil.name}: {coil.value}")

if name == 'main': logging.basicConfig(level=logging.DEBUG)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.run_forever()`](https://gist.github.com/latisen/effd27bcc932743ae2fe6f5e37ff1b9e)
yozik04 commented 2 years ago

can it be that another nibe library is installed locally?

rtitmuss commented 2 years ago

If you look on page 7 of the modbus manual there are instructions to download the available registers on a USB stick. Maybe that will help verify which registers are available on your heat pump.

On Mon, 11 Jul 2022, 14:36 Jevgeni Kiski, @.***> wrote:

can it be that another nibe library is installed locally?

— Reply to this email directly, view it on GitHub https://github.com/yozik04/nibe/issues/7#issuecomment-1180357323, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZOWUWFSODOJYVES3EK2TVTQINZANCNFSM53HLGLKA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

latisen commented 2 years ago

Accidantaly ran the file from the wrong dir. Now the error says:

DEBUG:asyncio:Using proactor: IocpProactor DEBUG:nibe.nibe.connection.modbus:Sending read request DEBUG:sockio.TCP(10.0.1.15:502):open connection (#1) Traceback (most recent call last): File "c:\Users\dick\OneDrive - AFRISO EMA AB\Dokument\nibe\dick_test.py", line 33, in loop.run_until_complete(main()) File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "c:\Users\dick\OneDrive - AFRISO EMA AB\Dokument\nibe\dick_test.py", line 24, in main await connection.read_coil(coil) File "c:\Users\dick\OneDrive - AFRISO EMA AB\Dokument\nibe\nibe\connection\modbus.py", line 25, in read_coil result = await asyncio.wait_for( File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 479, in wait_for return fut.result() File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\async_modbus\core.py", line 194, in read_input_registers return await self._send_message(request) File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\async_modbus\core.py", line 142, in _send_message return await self.protocol._async_send_message( File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\async_modbus\core.py", line 39, in send_message_tcp await writer.drain() File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\async_modbus\core.py", line 113, in drain await self._write_coro File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\sockio\aio.py", line 31, in wrapper await self.open() File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\sockio\aio.py", line 287, in open self.reader, self.writer = await coro File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\sockio\aio.py", line 158, in open_connection configure_socket(sock, no_delay=no_delay, tos=tos, keep_alive=keep_alive) File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\site-packages\sockio\aio.py", line 117, in configure_socket sock.setsockopt(socket.SOL_IP, socket.IP_TOS, tos) File "C:\Users\dick\AppData\Local\Programs\Python\Python39\lib\asyncio\trsock.py", line 82, in setsockopt self._sock.setsockopt(*args, **kwargs) OSError: [WinError 10022] Ett ogiltigt argument angavs (Invalid argument)

yozik04 commented 2 years ago

very interesting. Have no idea what argument it tries to send

latisen commented 2 years ago

seems to be something with the modbus connection

latisen commented 2 years ago

Strange thing is that I don't get that error on the HA Addon, will try more later tonight.

latisen commented 2 years ago

I'm up and running. Installed python and all req's on another Pi. about 40% of the sensors for VVM325S is added now.

latisen commented 2 years ago

@yozik04 Just want to test writing. How do I write to a coil?

yozik04 commented 2 years ago

Cool! Does it read all these 40% of sensors?

yozik04 commented 2 years ago

Update coil value and execute: await connection.write_coil(coil)

elupus commented 2 years ago

What is the status here? Would be cool to add the modbus support to home assistant native client, but we'd need a guinea pig.

yozik04 commented 2 years ago

Would be great but nobody tested it yet as I know.

elupus commented 2 years ago

@latisen can you export the csv of registers from your pump and post here. I think it should be same way as this manual: https://www.nibe.eu/download/18.3db69dc1795e0d992c5722/1622634529178/Modbus%20S-series%20EN%20M12676EN-1.pdf

Ps. Switch the pump to english first.

elupus commented 2 years ago

This is supported now.