Git Product home page Git Product logo

Comments (6)

gfwilliams avatar gfwilliams commented on June 4, 2024 1

Thanks! And thank you for the documentation update on the Server ID. Mine was set to 00 by default. I set it to 01 and uncommented SUNSYNK.server_id = 1 and that fixed it for me!

Out of interest, does it matter if the inverter is set as a master or slave?

I'll close this issue, but do you want me to add a PR for the script with the changes you suggested (or just feel free to copy it in yourself if it's easier)? I guess sunsynk/scripts/comms-test.py or similar, and a mention in the README?

from sunsynk.

kellerza avatar kellerza commented on June 4, 2024

Hi, the sunsynk library is used extensively by the homeassistant addon, in the same repo:

Init the driver and then simply read values with await read_sensors(list_of_sensors)

You can see this library as a wrapper (with sunsynk register info) over either one of the two modbus drivers: umodbus or pymodbus

from sunsynk.

gfwilliams avatar gfwilliams commented on June 4, 2024

Thanks for the speedy response! I just tried this, but sadly no luck:

import asyncio
import pprint
from sunsynk.definitions import ALL_SENSORS, DEPRECATED
from sunsynk.sunsynk import Sensor, Sunsynk
from sunsynk.pysunsynk import pySunsynk
from sunsynk.usunsynk import uSunsynk

#pprint.pp(ALL_SENSORS)
SERIAL = ALL_SENSORS["serial"]
sensors = [ALL_SENSORS["pv1_power"], ALL_SENSORS["pv2_power"]]

SUNSYNK = uSunsynk() 
#SUNSYNK = pySunsynk()
SUNSYNK.port = "serial:///dev/ttyUSB0"
#SUNSYNK.server_id = 1
#SUNSYNK.timeout = 10
#SUNSYNK.read_sensors_batch_size = 60

async def main():
  print("Connecting...");
  await SUNSYNK.connect()
  print("Connected. Reading...")
  await asyncio.wait_for(SUNSYNK.read_sensors([SERIAL]), 10)
  print("Serial "+SERIAL.value)
  #print("Reading 2...")
  #await asyncio.wait_for(SUNSYNK.read_sensors(sensors), 10)
  #print(sensors[0].value)
  #print(sensors[1].value)
  print("Finished");  
  
  
LOOP = asyncio.get_event_loop()
LOOP.set_debug(True)
LOOP.run_until_complete(main())
LOOP.close()

It gives me a timeout:

Connecting...
Connected. Reading...
Traceback (most recent call last):
  File "test.py", line 34, in <module>
    LOOP.run_until_complete(main())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 23, in main
    await asyncio.wait_for(SUNSYNK.read_sensors([SERIAL]), 10)
  File "/usr/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

It's a SunSynk 8,8kW, wired to the RS485 connector, with the wiring and USB adaptor as shown (using pins 1+2) in the pics on https://github.com/kellerza/sunsynk#hardware (there's no GND since the adaptor doesn't have it).

Does it look like the code I've got there is ok? Is there anything else I need to set up in the inverter to enable RS485?

edit: One thought - I do already have a Wifi adaptor plugged in the bottom. Could that be causing some kind of conflict? I also don't have a battery installed (still waiting for shipping!).

If/when I finally get this going, it is worth me doing a quick PR for it?

from sunsynk.

kellerza avatar kellerza commented on June 4, 2024

Hi, I would simpy change the read to await SUNSYNK.read_sensors(sensors)

So your main method would be:

async def main():
  print("Connecting...");
  await SUNSYNK.connect()
  print("Connected. Reading...")
  await SUNSYNK.read_sensors(sensors)
  print(", ".join(f"{s.name}={s.value} {s.unit}" for s in sensors))
  print("Finished");  

from sunsynk.

kellerza avatar kellerza commented on June 4, 2024

Also check the server ID & multiple serial connections - here

from sunsynk.

kellerza avatar kellerza commented on June 4, 2024

PRs are always welcome, you can add comms-example.py

The master/slave setting is only used for a multi-inverter setup. From my understanding is is not related to or affects the modbus master/slave client/server in any way

from sunsynk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.