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
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Solar PV Monitoring/Automation Thread

13468943

Comments

  • Moderators, Home & Garden Moderators Posts: 6,280 Mod ✭✭✭✭graememk


    I'm Polling my inverter every 10 seconds via wifi, and it seems fine,

    The rest of my system is setup for about 10 seconds too.

    As mine is just a normal inverter, they had different addresses, all im pulling is the string voltages, current, grid, temp, AC power and DC Power.

    Im just triggering the script from nodered and processing the output Json then into mqtt.

    I have a Home assistant instance running but havent really dug into it yet. Mostly working in emoncms.



  • Registered Users Posts: 189 ✭✭connesha


    +1 Same here.

    I'm polling the inverter every 10 seconds from a script outside HA, and publishing via mqtt. Was doing every 5 secs for a period previously too, and no issues so far. On Solis hybrid 5G.

    Also polling MyEnergi every 10 seconds to get Eddi heater loads/totals and publishing that via mqtt. Using https://github.com/CJNE/pymyenergi, keeping same MyenergiClient/Connection between invocations (lib modified locally to extract independent history for heater1 and heater2, so can use as Appliance1/2 in tesla-style-card)



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    Why go through hoops of python->mqtt->HA when you can just use the existing HA integration (which you could also modify)? https://github.com/CJNE/ha-myenergi. Less moving parts.



  • Registered Users Posts: 189 ✭✭connesha


    Easier modify. It didn't give what I needed out of the box. Would have had to modify both HA and the lib to get it.

    Also, have all the infrastructure in place already for other events so was easy. And I find running outside HA is so much easier/less finicky to setup, debug, etc...



  • Registered Users Posts: 468 ✭✭thebackbar


    Does any inverter provide the ability to control the charging of a battery via an API ? For example if tomorrow is promised sunny can you set your battery to charge to x percent over night, but if tomorrow is expected to be cloudy you would fully charge your battery at offpeak rates ?



  • Registered Users Posts: 6,181 ✭✭✭championc


    I don't think so out-of-the-box.

    I am currently doing it with Node-Red to my Sofar ME3000 Storage Inverter.

    The RS485:port is connected to an sofar2mqtt which sends the data to Node-Red - and receives instructions back. The ME3000 is set to passive mode, which allows commands to then be sent to the inverter.

    So it can be told to start charging at midnight, and stop when SOC% reaches xx%, discharge overnight or go into Standby unit maybe 09:00.

    So passive mode turns the inverter into a dumb device. You can tell the inverter to Charge, Discharge, or go into Auto or Standby.

    I also use Node-Red to control my Eddi and Zappi, only turning them on when my batteries SOC hits 98%

    Post edited by championc on


  • Registered Users Posts: 468 ✭✭thebackbar


    Very interesting thanks ! I have been given the option of a solis, goodwee or a Huawei Inverter.

    Afaik with the solis inverter the api doesn't support this capability, so I need to see what type of api the other two have.



  • Moderators, Home & Garden Moderators Posts: 6,280 Mod ✭✭✭✭graememk


    You can interface with the solis over modbus though the wifi module (over IP)

    You can change most if not all of the settings on the hybrids



  • Moderators, Science, Health & Environment Moderators Posts: 4,726 Mod ✭✭✭✭Tree


    I have the Huawei SUN 2000, you need a higher level account (installer) on fusion solar to mess w/ the battery config. Mine is set for time of use (TOU) and you can configure what times it charges from the grid and what time it discharges.

    Right now I have it discharging all teh time except Saturdays (BG smart tariff with a free weekend day), so I draw from the grid on saturdays even if the battery is full. You can't set "50%" but you can set it to charge from the grid for an hour or so, and that's the same. The 5kW takes ~2h to charge.



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


    Yup the GivEnergy ones have a nice (new) API where you can query and modify settings.

    GivEnergy API Documentation (v1.5.2)

    I actually still use the old API, but it doesn't look that much difficult to swap. I'll probably keep using the old API until they deprecate it and break me and then I'll have to get off my arse and migrate to the new one :-)



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 269 ✭✭S'


    I had a look at trying to read data over modbus via a PLC that I have on my network on port 502. I can ping the wifi stick (192.168.8.100) and have my PLC at (192.168.8.101).


    does below look right?




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


    I would say the main reason for not allowing remote control is security. The other thing is that the communication between inverter and cloud is not direct and instant. Since inverters are connected to the cloud it is ussually one way street, the data is going out. There is no direct connection to the inverter from outside unless you configure port forwarding(security risk). Solis has OTA firmware upgrades but in this case inverter still initiating the connection at certain time and checks if there is a firmware available for it in the cloud.

    It is still possible to control solis settings through modbus using Solarman V5. I have posted earlier my code https://github.com/NosIreland/solismod that allows to modify modbus registers remotely. It subscribes to mqtt topics that you define and then makes changes in inverter. I use node-red to send desired mqtt topics to broker. I use it to change charging intervals and charging current based on next days weather forcast.



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


    No. It isn't Modbus TCP. It's Modbus RTU encapsulated in the proprietary Solarman V5 protocol.

    Check out pysolarmanv5 which handles the encapsulation for you.



  • Registered Users, Registered Users 2 Posts: 269 ✭✭S'


    Ah Ok, that a pity. I could remove the cloud service and connect to my PLC over RS485 but ideally would like to hold onto the app for remote viewing.

    I'm not one bit familiar with python but what would be the best/easiest way to add this to my HA.

    I have HA running on Windows 10 VM on a QNAP NAS



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




  • Registered Users Posts: 861 ✭✭✭tails_naf


    Hi All,

    Just got Jonathan's pysolarmanv5 running - and can query the registers of my solis inverter (starting at 33000..).

    To get this integrated into HA are these the options as it stands:

    1. Use pysolarmanv5 with a register mapping and write the data to HA with MQTT or similar
    2. if some has done this, can you share that script?
    3. The other alternative that was mentioned is here: https://github.com/StephanJoubert/home_assistant_solarman
    4. This seems to have a lot of the work done and all we need is the YAML
    5. Something else?

    (Jesus formatting is a dose on this new site, tried to simply have an indented list and couldn't get it to work....)



  • Registered Users Posts: 189 ✭✭connesha


    See page 1 of this thread. @reklamos shared a script that pulls from pysolarmanv5 and publishes via mqtt



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


    Hey guys is there a register for PV1 and PV2 power or just have to get it by pv1 A * pv1 V?



  • Registered Users, Registered Users 2 Posts: 315 ✭✭john__long


    Couldn't get @reklamos' register writing to work for my Solis inverter. Wasn't able to scan the registers properly.

    Was chancing a 'modbus.read_input_register_formatted(register_addr=43144, quantity=1)' to see if I can also modify my charging times, but it's throwing the below.

    Will crawl into the attic like an animal so! :D


    Exception has occurred: error

    unpack requires a buffer of 2 bytes

     File "C:\Users\home\Python\solismon3\pysolarmanv5\pysolarmanv5.py", line 154, in _get_modbus_response

       modbus_values = rtu.parse_response_adu(mb_response_frame, mb_request_frame)

     File "C:\Users\home\Python\solismon3\pysolarmanv5\pysolarmanv5.py", line 199, in read_input_registers

       modbus_values = self._get_modbus_response(mb_request_frame)

     File "C:\Users\home\Python\solismon3\pysolarmanv5\pysolarmanv5.py", line 212, in read_input_register_formatted

       modbus_values = self.read_input_registers(register_addr, quantity)

     File "C:\Users\home\Python\solismon3\client_example.py", line 17, in main

       data = modbus.read_input_register_formatted(register_addr=43143, quantity=1)

     File "C:\Users\home\Python\solismon3\client_example.py", line 45, in <module>

       main()



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


    Not on the Solis, no. Either multiply them, or use the total DC power for all strings in 33057/33058.

    I pushed my draft yaml to GitHub yesterday. Have a few more changes to make before I file a PR, but it should be good enough for testing.



  • Registered Users Posts: 861 ✭✭✭tails_naf


    Thanks. Would be good to put all of this info in a sticky/modify the first post with all the links.

    I spent a bit of time updating my previous Web scraper to use pysolarmanv5, and now thabks to you pointing it out see reklamos has done exactly this (and better than I had!). My scraper was publishing to influxdb, so may add this as an option to his version.

    Next step is the HA integration of all this. Currently I have my solar details in a grafana dashboard, but no HA integration at all.



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


    It depenend what you want to see/do in HA. I am pulling close to ~100 registers as I want to see them in Grafana but in HA I just need couple of them for automation. In my implementation I use Prometheus instead of InfluxDB and also metrics are published to mqtt. HA pulls the few mettrics that it needs from mqtt.



  • Registered Users Posts: 130 ✭✭fael


    Really nice work! Am away for a few days, but when I get back I'm going to set up your .yaml and tinker with it.



  • Registered Users Posts: 189 ✭✭connesha


    I've shared code for Solar Forecasting, battery charging and EDDI and Inverter monitoring, on GitHub: https://github.com/connesha/home-energy-mgr-ext-main

    There's a good deal of information in the README for getting setup and running it. It was written over the past month or so, and has been running in some form during that period. So far it has provided what I wanted for my setup. If anyone tries it out and has issues, let me know.

    There were a few enquiries about this post (#78) on Forecasting and Charging, so this is all the code behind it, and a few basic Home Assistant integrations.

    There are lots of people on here with more advanced setups, done in different ways. This runs outside HA by design; others run within HA, but that's not the model I'm going with for now at least. Hopefully it's of some use to those getting setup.

    It is a Work-In-Progress, and all the usual disclaimers that come with that. It is my first python programming, and first programming of any sort in about 10 years, so that's my excuses out of the way for the parts that are not so pythonic ;-)

    Parts are built on top of code shared previously in this forum by @Jonathan, @reklamos and @garo, so thanks to them for also sharing.

    Also, some parts are following ideas discussed with @bullit_dodger and @graememk



  • Registered Users Posts: 430 ✭✭Geeyfds53573


    Works fine but does need the time of use to be turned on so can’t discharge at the same time - #AnotherOne who would really like the time of use settings to be exposed in the pvsolarmanv5 please @Jonathan but very very handy indeed thank you. I’ll have more of a look when I get time.



  • Advertisement
  • Registered Users Posts: 861 ✭✭✭tails_naf


    OK, so working off your code, my local copy now has InfluxDB working, with the following changes:

    1. Allow Prometheus, MQTT and Influxdb to be individually enabled
    2. Influxdb support added, and config options for it included in config.py
    3. Optional Conversion of the register value based on the unit listed in the description string.
    4. Optional alternative name for a subset of influxdb fields - this purely is because I was using ginlong-scraper before and wanted to keep the same names for the fields it supported. This is enabled in registers.py
    5. Optional MQTT authentication if user/pass provided

    @reklamos - if you are interested in picking these up I can create a pull-request.

    Also, could you share the homeassistant config you have for the subset MQTT published values you display?



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




  • Registered Users Posts: 430 ✭✭Geeyfds53573




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


    I publish single json topic to MQTT instead of individual ones, this makes it faster and cleaner. I noticed with my testings before that if I do individual topics for each metric I was getting inconsistent behaviour from MQTT as it was not able to process topics fast enough. This is even more relevant to people running on RPI. But probable majority will not run into this since not all are pulling 1000s of metrics.

    in configuration.yaml I have sensor: !include devices/sensors.yaml and then in devices/sensors.yaml I define my MQTT sensors that I want to pull to HA like this:

    - platform: mqtt
      state_topic: "solis/METRICS"
      unique_id: "sensor.today_generated"
      value_template: "{{ (value_json.today_generated | float) /10}}"
      name: "Generated Today"
      device_class: energy
      unit_of_measurement: "kWh"
      state_class: measurement
    


  • Registered Users Posts: 861 ✭✭✭tails_naf


    I didn't change the mqtt publish, except add optional authentication details, so still a single topic. Was just wondering if you've some HA code for arranging the panels to display the relevant info nicely. I'm new to HA so what I have looks a bit rough



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


    I do not have anything special, I use tesla-style-solar-power-card in HA as that shows everyting I need in one place.

    My card config is below but you'll need to adjust them based on your entity names.

    type: custom:tesla-style-solar-power-card
    grid_consumption_entity: sensor.meter_power_in_modified
    house_consumption_entity: sensor.total_load_power_modified
    grid_to_house_entity: sensor.meter_power_in_modified
    grid_to_battery_entity: sensor.grid_to_battery_power_in_modified
    generation_to_grid_entity: sensor.meter_power_out_modified
    generation_to_battery_entity: sensor.battery_power_in_modified
    generation_to_house_entity: sensor.solar_to_house_power_modified
    battery_to_house_entity: sensor.battery_power_out_modified
    battery_extra_entity: sensor.battery_capacity_soc
    appliance1_consumption_entity: sensor.bypass_load_power
    appliance1_icon: mdi:server-network
    generation_icon: mdi:solar-power
    house_extra_entity: sensor.house_load_today
    generation_extra_entity: sensor.generated_today
    grid_extra_entity: sensor.imported_today
    grid_entity: sensor.meter_power_in_modified
    house_entity: sensor.total_load_power_modified
    generation_entity: sensor.total_solar_output_power
    battery_entity: sensor.battery_capacity_soc
    


  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy




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


    I know, but I see no reason why I should not use it when it works for me. I have not seen any disadvantages on having negative value on battery.



  • Registered Users Posts: 861 ✭✭✭tails_naf


    Thanks, have this working now. Bit of messing as had to install the add-on manually as I can't get HACS (my install is 2021.3 and 2021.9 or newer is needed for HACS), but once that was done it was just adding the mqtt sensors linked to the right values.

    It's great to see the live values (or at worst 30 seconds old!) as solis cloud was at least 5-10 mins stale at the best of times.



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    So I've got the latest and greatest from https://github.com/StephanJoubert/home_assistant_solarman and have the config:

    solarman:
      name: Solis
      inverter_host: 192.168.0.130
      inverter_port: 8899
      inverter_serial: <snip> 
      inverter_mb_slaveid: 1
      scan_interval: 30
      lookup_file: solis_hybrid.yaml
    

    But, I'm getting nothing, no entities and nothing in the logs. Any idea why? Manually trying the example from pysolarmanv5 works fine with the serial and IP (static).



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


    Since 20e3280, config is via the UI. Docs need a tidy up ahead of next release.



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    I saw that commit message, where in the UI? Can't find it in my integration.



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


    Configuration -> Devices and Services -> Integrations -> Set up a new integration -> Solarman



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


    How do you guys enable/disable grid charging of the battery? python I assume? What registers do you set? Can you share that code pls.

    Is there an easy way to trigger that directly from HA Nodered and not have to mess with sending mqtt messages to the pi that's running the python code?

    Has anyone here managed to get pysolarmanv5 code to run directly from nodered?



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    Ah, there it is. Weirdly it wasn't there last night after installing both manually and via HACS and post-restart. It's working great now, cheers for putting the changes in for that integration. Do you have any more features planned for it?



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


    https://github.com/NosIreland/solismod works with nodered. Nodered published to mqtt and solismod pushes to solis.



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


    Sweet, so is this ready for prime time now?

    Do I still need a pi/docker/etc to run the python code or is it all runnable from within nodered now? Including the code that polls the registers I mean



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



    To-do list is broadly as follows;

    • Integrate pysolarmanv5; You might notice the occasional corrupted read. This is due to the current implementation attempting to parse the 0x1045 keepalive frames as modbus response frames. These are handled in pysolarmanv5.
    • Add support for other Modbus function codes 1,2,5,6 and 16.
    • Add support for bitwise operators to allow individual bits be exposed as sensors

    Pull requests welcome. 🙂

    See post #278 above. BIT01 controls the timed charge mode. You'll need to read 43110 first to confirm what the value is first before XORing with 0x2 to set.



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    Cool, are you doing batch reads currently? I've tried cranking up the update rate and it's choking on anything faster than every 10 seconds which is surprising as I can read many more registers every 2 seconds from the SolaX inverter no problem.



  • Registered Users, Registered Users 2 Posts: 3,971 ✭✭✭mp3guy


    Looks like it! Going to start hooking things up but I think this is it.



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


    Yuo need to run python code somewhere. You can run it directly in the OS where you have HA/Nodered or you can run it as container. I have everything conatinerized as it makes it easier but do what works best for you.



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


    Running HA OS so not sure if it's possible to add docker to it. Nodered is an addon of HA OS.So maybe this won't work for me, not a linux master or anything, in fact it's my least favorite OS 😁



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


    Yes, but the Solis registers are a bit all over the place. The 50 or so sensors that are extracted as based on three reads requests of 100 registers each.

    30 seconds polling is more than enough for my needs, so I haven't investigated much further, but I suspect the lag is introduced by the WiFi dongle. It doesn't help however, that the baud rate is only 9,600. @reklamos might be able to confirm the source of the slowness as he was previously reading directly off the RS485 port (bypassing the WiFi dongle).



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


    You can run the script on windows or in docker on windows machine also. I actually write and test code on windows.

    @mp3guy how many registers are you trying to read? Are you reading them in blocks or looping through each? As @Jonathan mentioned baud rate is only 9600. I am reading total of 129 registers devided in 8 blocks. It takes ~3-4s to do that but there is also overhead of formating, presenting and publishing. I would say the whole read is probably closer to 2s. I've read in some unoficial document that you should not exceed 100 registers in one go on solis modbus. My largest block has 34 registers.



  • Advertisement
Advertisement