Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Solar PV Monitoring/Automation Thread

1356775

Comments

  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan


    Pushed a new version of pymodbusv5 (v2.1.0) to github there which has much improved error checking. Thanks to those that sent debug logs.


    EDIT: @reklamos Looking at your code, that probably means some breaking changes for the error checking you recently added on your side. Sorry!



  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan




  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    Yep that tallies with my inverter.

    I wonder why they are having the control of the hybrids behind a NDA...

    Isnt there some docs out there regarding control of the hybrids already?



  • Registered Users, Registered Users 2 Posts: 793 ✭✭✭reklamos


    Thanks, will check it

    It is difficult to figure out which inverters/wifi sticks these apply. I see hybrid listed but the register do not match what I have at the moment.

    Never mind the page says that different model have different maps. Also looks like RHI series in US have different map to the ones in EU. Not sure I understand the logic why Solis try to over complicating this.

    I do no think the documents that floating around are the official ones.



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    It could be because the us is split phase where we are single or 3(on the continent?)


    I suppose it would be handiest for me to loop through, read the registers and publish to mqtt.



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,861 ✭✭✭tnegun


    I haven't looked at the document provided by @Jonathan yet but wanted to share this one that Solis sent me today.




  • Registered Users, Registered Users 2 Posts: 793 ✭✭✭reklamos




  • Registered Users, Registered Users 2 Posts: 2,602 ✭✭✭SD_DRACULA


    Great work @Jonathan /@reklamos with the solis stuff.

    Still trying to find some time to see if @Jonathan 's code can be made to run via node-red, the readings from the solis server are unreliable and have skewed the data a few times in HA for me and had to manually edit them.



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    The way I'm thinking of doing it is have the script be triggered by node red, and either output a json object or push it direct to mqtt



  • Registered Users, Registered Users 2 Posts: 2,602 ✭✭✭SD_DRACULA


    I have node-red currently set up to pull all data from solis server and then send to mqtt.

    Had no luck in the past in getting python to run via node-red, do share if you ever get it working 😁



  • Advertisement
  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    I have got it to work before but it was just triggering the script, not running "in" Node Red



  • Registered Users, Registered Users 2 Posts: 2,602 ✭✭✭SD_DRACULA


    Yeah could probably do that but I rather not add one extra device like Pi to just run this, node-red runs on my HA instance so getting to run there would be perfect.

    I know it can be done but a bit beyond my skills.



  • Registered Users, Registered Users 2 Posts: 793 ✭✭✭reklamos


    Everyone will have different setup but here is how I have it at the moment

    In my setup everything runs in docker(HASS, mqtt, nodered etc). I have created docker image for the script also and uploaded to docker hub. The instructions how to run it is in github.

    The script allows to configure mqtt server ans sends metrics to is as single json object(I had each metric separately but it as too much for mqtt to handle in one go. Instead to single IO it had to take over a hundred at once.

    Mosquito MQTT and nodered are both talking to Hass. I only pull metrics that I want from MQTT to Hass by defining sensor in configuration.yml file

    - platform: mqtt
      state_topic: "solis/METRICS"
      name: "Total house load"
      unique_id: "sensor.total_house_load"
      unit_of_measurement: kWh
      value_template: "{{ value_json.total_house_load_2 }}"
      state_class: total_increasing
      device_class: energy
    

    Once Hass restarts it will create entity 'sensor.total_house_load' and this is where it will pull metric in Hass. If nodered is integrated into Hass then you will also see the same in nodered.

    You can pull from MQTT directly to nodered. Just use 'mqtt in' node and subscribe to the relevant topic.

    As mentioned I only pull basic stuff to Hass as there is no need for all the metric I just want to be able to use the Energy feature and also this on dashboard as it give quick representation on what is happening.

    Action 06-01-2022 13-27-13.gif




  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    @Jonathan ,

    as I'm coding at night i cant test, but in the bit of code posted earlier to scan the ports, it pulls out

    !!!!!!!!!!!FOUND!!!!!!!!!!! 2999 [172]

    When i call this:

    modbus.read_input_registers(register_addr=3005, quantity=1)

    Does it return a value in square brackets?



  • Registered Users, Registered Users 2 Posts: 793 ✭✭✭reklamos


    It is a list so it comes in brackets, if you to change quantity to 2 it would be [123, 456]

    Edit: the output type is a list.



  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan


    If you need to get a single value rather than a list, use read_input_register_formatted() and read_holding_register_formatted(). These functions will do any combining of adjacent registers for you, as well as signing, scaling, bitmasking/shifting etc.

    @reklamos Just added an updated version of the register scanner to the repository. Made a few tweaks to formatting and to catch KeyboardInterrupt. Previous version was a bit awkward to kill. Had to resort to kill -9. 😂



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    ahhh.


    ok do i have to worry about the last argument for now?

    read_input_register_formatted(self, register_addr, quantity, **kwargs):

    I'm only pulling out 9 values, scattered about the list. I don't think i need to pull everything..



  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan


    No. The last argument (**kwargs) is a special parameter in Python to allow you to pass keyword arguments (basically optional arguments). See last four example requests examples/client_example.py to see how it is used.

    Post edited by Jonathan on


  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    Thanks for your help, Havent really used python much. most of my experience is in C and C# (and node red javascript!) I find python so "wordy" (and no curley brackets!)

    Have something basic that I can trigger from node red and output some Json back out. As I can already monitor the CT for solar, I can use that to trigger, otherwise id have to either a) ping the logger or have some code to activate at daytime.

    @SD_DRACULA Im just using a execute node to trigger the nodered script, so I'm not a huge amount of help for you there unfortunately.

    Ironically I had moved my node red flows to a plugin/jail on my truenas box, so I havent even attempted installing python on that yet. Running it on the Pi that is hosting my emoncms.


    image.png




  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    So my code runs fine on my pc, Once I move it to the pi, it fails.

    What am i missing? a dependancy?

    Traceback (most recent call last):

     File "main.py", line 95, in <module>

      main()

     File "main.py", line 59, in main

      thislist = modbus.read_input_registers(register_addr=3005, quantity=38)

     File "/home/pi/.local/lib/python3.7/site-packages/pysolarmanv5/pysolarmanv5.py", line 206, in read_input_registers

      modbus_values = self._get_modbus_response(mb_request_frame)

     File "/home/pi/.local/lib/python3.7/site-packages/pysolarmanv5/pysolarmanv5.py", line 157, in _get_modbus_response

      mb_response_frame = self._send_receive_modbus_frame(mb_request_frame)

     File "/home/pi/.local/lib/python3.7/site-packages/pysolarmanv5/pysolarmanv5.py", line 152, in _send_receive_modbus_frame

      mb_response_frame = self._v5_frame_decoder(v5_response_frame)

     File "/home/pi/.local/lib/python3.7/site-packages/pysolarmanv5/pysolarmanv5.py", line 127, in _v5_frame_decoder

      raise V5FrameError("V5 frame contains invalid a Modbus RTU frame prefix")

    pysolarmanv5.pysolarmanv5.V5FrameError: V5 frame contains invalid a Modbus RTU frame prefix



  • Advertisement
  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan


    Doesn't appear that way from the traceback. Could just be a transient thing if the data logger was accessing data for Solis Cloud at the time.

    If it always fails from the Pi, turn on verbose and post the SEND and RECD V5 frames.


    EDIT: Could also be a different Python version, but breaking changes between minor versions are rare enough.



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    ah, on pc its 3.9.9. pi has 3.7.3. Will investigate more.



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    While I'm poking around looking how to update python.. and not break other things!

    i tuned on verbose logging, It doesnt even get the the SEND and RECD frames. but a new error has flagged up.

    TypeError: hexlify() takes exactly one argument (2 given)



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    so in 3.7 hexify() is binascii.hexlify(data)

    but in 3.9 (and 3.8) its binascii.hexlify(data[, sep[, bytes_per_sep=1]])

    @Jonathan FYI



  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,299 Mod ✭✭✭✭Jonathan


    Thanks. I will mark as Python 3.8+ for now. If I get a chance I'll see can I backport support for earlier 3.x versions.



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    Yeah currently having a mare of a time trying to get it to work in 3.9.9 on the pi.

    I have 3.9.9 installed but it's not installing your code. I think it's something on my end tho. You'd think they'd have the apt version of python a bit newer!



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    With a lot of faff (I think its because something was screwy.. and python not compiling correctly or something) I have python 3.10.1 installed! and it finally will install your library.

    Testing tomorrow and logging... hopefully



  • Moderators, Home & Garden Moderators Posts: 7,017 Mod ✭✭✭✭graememk


    Huzzah, Pulling data in now, Will be interesting to see the difference in performance between my two aspects

    image.png


    Post edited by graememk on


  • Registered Users, Registered Users 2 Posts: 2,662 ✭✭✭bullit_dodger


    I got my own scraping working on Friday. Problem for me is that they aren't like-for-like sizing.

    image.png

    I guess I could "normalize" as in production per 1Kwp. Though if anyone has any ideas.....shoot.



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 793 ✭✭✭reklamos


    Nice to see both of you got it running.



Advertisement