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

Options
1161719212270

Comments

  • Registered Users Posts: 32 scuzzie2k


    Ok, I need to get solismod to run so I can write back to the Invertor, I have got all this working with MQTT and changing settings but this is where I am having issues getting this to run as its Python and needs some other requirements that need to installed on the PI, which goes on reboot The HA is a setup from their website which looks like yes it runs as a docker as installed on the card via balenaetcher. trying to see if i can find instruction show to install it all manually.



  • Registered Users Posts: 32 scuzzie2k


    Seems you need their docker unit to have Home Assistant OS otherwise its only the Core version.😕



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


    If you're just starting out, I'd recommend going with Home Assistant OS. Download the rp4-64 image from here and write to your SD card.

    Once you become more familiar with the setup, you can then look at Container/Core. The backup/restore process is rather good so migrating between them is pretty painless.



  • Registered Users Posts: 32 scuzzie2k


    This is what I have and is running.... but you cannot run anthing outside of it for example solismod on the same RPI as its a docker, this is the issue I am facing..... once I can figure this out I will be good to go.



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


    Yes, everything within HAOS is a container. If you only need to change a few registers, I'd investigate @connesha's AppDaemon suggestion first.

    However, it should also be possible to run Solismod within HAOS as a third-party repository Add-on. See the example addon or zigbee2mqtt as examples. Should just be a case of adding a few helper files to the Solismod repository (or maybe ask @reklamos nicely for some assistance 😋).



  • Advertisement
  • Registered Users Posts: 32 scuzzie2k




  • Registered Users Posts: 189 ✭✭connesha


    Yea, to keep to simple @scuzzie2k , here is what I setup with another poster here. It gives all the tools you need to read registers and to write registers, so you can do pretty much all your automation (incl charging) in HA without needing any of your own code. There are lots of other ways of doing it, but this was one of the simpler ways, and everything runs within HA (you don't need MQTT, SolisMod, other services , etc...).

    Again, you can always sub out parts of it later if you want to do different/more advanced stuff.

    (in my own setup, I do run stuff outside HA, in system based on/similar to solismod, and its great. It did take quite a while, and knowledge, to setup, so, for a new starter, what I'm talking about here is a basic way that should give all you need)

    1) Reading inverter state

    Use this: https://github.com/StephanJoubert/home_assistant_solarman

    If you need additional registers, then its pretty easy to modify it locally and add additional registers (registers defined here https://www.scss.tcd.ie/Brian.Coghlan/Elios4you/RS485_MODBUS-Hybrid-BACoghlan-201811228-1854.pdf)

    2) Writing to the Inverter

    The inverter is configured by writing a holding register. I did a simple AppDaemon app, that wraps PySolarManV5, and provides a simple interface to HA, so that you can call it like any regular HA script. E.g. to write a register, you would just put something like this into your HA automation (writes value 33 to register 43110):

      - service: script.inverter_write_holding_register
        data:
          register_addr: 43110
          register_value: 33
    


    And that's it - this should be everything you need for reading and writing any register, doing any HA automation, charging, buttons, etc... No MQTT needed, everything runs inside HA


    If you want to go this route, let me know. I'll need to do a write-up of the AppDaemon app, share the code etc. so its useful for any others on here too. And all you'll need to do is drop a few files into a folder, 2 or 3 HA configs, and it's good to go.



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


    Oh this is interesting for me too, I think I'm in the same boat as scuzzie there, got my HA OS running a pi4 and then a pizero2 with raspbian that I use to execute pysolarman5 and mqtt on.

    Would like to have it all run the pi4 but my python skills are close to 0 and I also hate linux 😂

    Do you have the appdaemon stuff somewhere on github perhaps?



  • Registered Users Posts: 793 ✭✭✭reklamos


    I don't use HAOS since I like flexibility :) but as @connesha wrote these are standard registers. If you can read registers directly from HA then you should be able to write. I use MQTT as I have plenty self-made devices, not all of them are part of HA and MQTT gets them all talking to each toher.



  • Registered Users Posts: 32 scuzzie2k


    Is anyone using tesla-style-solar-power-card with Solarman.sensors in HA? if so could you share what have you got set to? i cannot get my head around what need to point to what and getting some very unrealistic numbers.



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



    First see if you get proper entity values directly. If values are fine then adding them to tesla-style-solar-power-card is simple enough. If values are not correct then you need to correct them with templates. It is hard to tell what is wrong and how to fix when we do not see anything. Data is king.



  • Registered Users Posts: 189 ✭✭connesha


    The following shows how to configure inverters (write holding registers) from Home Assistant using a custom AppDaemaon app, exposed as simple script in HA.

    My own setup is on a Solis Hybrid 5G inverter, and its working well on that. It'd probably work for other setups too, but that hasn't been tried.

    No coding knowledge should be required to get this running.


    Prerequisites

    • Have HA setup and be comfortable doing basic configuration/automation
    • Have a file explorer/editor in HA (I use Visual Studio Code)
    • Have AppDaemon (AD) installed in HA, and ideally a basic Hello World AD app working
    • Know how to access the AppDeamon Web UI and look at logs (in case you need to do any debugging)

    Setting up the App

    • Extract the attached "apps.zip", and place the files your appdaemon->apps folder, preserving the folder hierarchy (note, if you already have your own apps, you'll need to merge apps.yaml)
    • In the file inverter.py, change the INVERTER_IP and INVERTER_SERIAL to match yours
    • Then, you need to tell it how to find the umodbus lib. Go to HA->Settings->Addons->Appdaemon->Configuration
    • Add python packages "datetime" and "umodbus". It should look like this (ignore the mysql one, that's for a different app)


    That should be the app all setup.


    Calling the app

    You can't easily call directly from HA to AD, so instead, we call a dummy script on the HA side, and listen for its invocation on the AD side. You could listen for any event; I'm using a script invocation event as it seems the most natural. To do it, put the following into your scripts.yaml

    # ----------------------------------------------------------------------
    # AppDaemon
    # ----------------------------------------------------------------------
    appdaemon_passthrough:
      alias: "AppDaemon Passthrough"
      sequence:
        delay:
          milliseconds: 1
    
    inverter_write_holding_register:
      alias: "Inverter Write Holding Register"
      sequence:
        - service: script.appdaemon_passthrough
          data:
            action: inverter_write_holding_register
            register_addr: "{{ register_addr }}"
            register_value: "{{ register_value }}"
    

    And that's everything done.

    When calling this, you can ignore all the AppDaemon stuff, and the fact that its a dummy script. Just treat it as a regular HA script that you can call from buttons/scenes/automations. For instance to set holding register 43110 to value 33 at 8pm, you call it like this.

    - alias: 'random test automation'
      trigger:
      - platform: time
        at: '20:00:00'
      condition: []
      action:
      - service: script.inverter_write_holding_register
        data:
          register_addr: 43110
          register_value: 33
      mode: single
    


    Other Notes

    In inverter.py there is a commented out line (line 21) which would verify registers and values being passed in. Recommend you uncomment this line and update _verify_safe_register to allow only the registers and values you plan on setting. This should help prevent mess-ups if you change a register by accident while testing your automations.

    If does a lot of retries internally, but ultimately there is no guarantee it'll succeed. In my own experience, is has been solid; it has not failed since started using it a couple of months ago. You can verify by reading registers using solarman or SolisMod.

    I use the passthrough script and ActionReceiver for a bunch of other actions, like updating a SQL DB when a user presses a button. So if you do have other random python tasks, you can expand on the actions you pass in. You can call the appdaemon_passthrough script directly (the inverter one is just a wrapper for convenience)


    Thanks to @Jonathan for pysolarmanv5. It is included as source, grabbed from GitHub a couple of months ago. The only modification made was for logging.

    Important: this is test code, provide as-is. It hasn't hadn't had any testing, and has only been run by a couple of people, so the usual disclaimers go with it. Writing to inverters changes stuff, so make sure you know what you are changing and are comfortable doing it (and backing yourself out of it in case of issues)



  • Registered Users Posts: 32 scuzzie2k


    I have this below but the House draw sometimes eems incorrect.


    type: custom:tesla-style-solar-power-card

    battery_to_house_entity: sensor.solarman_battery_power

    grid_to_house_entity: sensor.solarman_meter_active_power

    generation_to_house_entity: sensor.solarman_inverter_dc_power

    battery_extra_entity: sensor.solarman_battery_soc



  • Registered Users Posts: 34 Fred7631


    @connesha Great work, looks like it will do exactly what I want. Got an issue though. I believe I have followed everything you wrote but getting errors when trying to run a script. Any ideas?




  • Registered Users Posts: 189 ✭✭connesha


    Great.

    Looks like your validation inside _verify_safe_register is failing. I'm guessing you un-commented line 21, but didn't update the logic in _verify_safe_register to match your specific needs. Is that correct?

    If so, then comment out line 21 again (like it was in my original code drop). I'd expect it to work then.

    Later on you can go back and add your own specific validation inside _verify_safe_register (if you're comfortable with python. If you're not comfortable with python, its fine; this only provides some extra safety, it'll all work fine without it)

    If you want to post your logs again after you run with line 21 commented out, even if it works, I can take a look to see that all looks ok.



  • Registered Users Posts: 34 Fred7631


    Thanks. For some reason, the file was not saving when I was adjusting values. Restarted everything and now all sorted :)



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


    @connesha thanks for the writeup above, I managed to install app daemon to my HA instance and wondering about this part:

    # ----------------------------------------------------------------------
    # AppDaemon
    # ----------------------------------------------------------------------
    appdaemon_passthrough:
      alias: "AppDaemon Passthrough"
      sequence:
        delay:
          milliseconds: 1
    
    inverter_write_holding_register:
      alias: "Inverter Write Holding Register"
      sequence:
        - service: script.appdaemon_passthrough
          data:
            action: inverter_write_holding_register
            register_addr: "{{ register_addr }}"
            register_value: "{{ register_value }}"
    

    Is that the bit that goes into scripts.yaml (or where ever all the scripts go usually)?



  • Registered Users Posts: 3,188 ✭✭✭irishchris


    # ----------------------------------------------------------------------
    # AppDaemon
    # ----------------------------------------------------------------------
    appdaemon_passthrough:
      alias: "AppDaemon Passthrough"
      sequence:
        delay:
          milliseconds: 1
    

    This goes into the scripts.yaml 👍



  • Registered Users Posts: 3,188 ✭✭✭irishchris


    ..



  • Registered Users Posts: 189 ✭✭connesha


    Almost Chris ;-). I added the wrapper/utility script inverter_write_holding_register after we set you up, so you may not have seen that before. It doesn't change anything in the operation of it, its just a trivial wrapper that makes it all a little more readable when you're making your automations.

    So, all of this goes into your scripts.yaml @SD_DRACULA :

    # ----------------------------------------------------------------------
    # AppDaemon
    # ----------------------------------------------------------------------
    appdaemon_passthrough:
      alias: "AppDaemon Passthrough"
      sequence:
        delay:
          milliseconds: 1
    
    inverter_write_holding_register:
      alias: "Inverter Write Holding Register"
      sequence:
        - service: script.appdaemon_passthrough
          data:
            action: inverter_write_holding_register
            register_addr: "{{ register_addr }}"
            register_value: "{{ register_value }}"
    

    The first script (appdaemon_passthrough) is the generic dummy / no-op script that AD listens for. You could call this directly if you like, and pass in the "action" parameter as well as the 2 register ones. (this is what Chris is doing now, and I was doing at that time too)

    The second script (inverter_write_holding_register) calls the first (appdaemon_passthrough) with a hard-coded action, and passes the 2 register parameters straight through as-is. It just means the caller (your automations) gets a nicer looking script with a specific name, and it sets the action so you don't have to.


    Chris, if you want to update yours, you can do this: (this part applies only to IrishChris):

    Add the inverter_write_holding_register script to your scripts.yaml

    Then, anywhere you were calling this before:

     - service: script.appdaemon_passthrough
        data:
          action: inverter_write_holding_register
          register_addr: 43110
          register_value: 33
    

    call this instead:

     - service: script.inverter_write_holding_register
        data:
          register_addr: 43110
          register_value: 33
    

    There was no functional change since you got the drop a few weeks back IrishChris, so you don't need to do this, or update anything else; this is all just cosmetic. Great to hear its working well for you 👍️



  • Advertisement
  • Registered Users Posts: 2,278 ✭✭✭SD_DRACULA


    Thanks guys, got them in there now.

    Question, right now that 43110 register reads as 49, what does setting it to 33 do or how do you work that out?

    How do I disable the grid charge, set the register back to 49 via an automation when I want it to stop charging?



  • Registered Users Posts: 793 ✭✭✭reklamos


    Yesterday I have checked how my solar prediction worked over last 30 days and it looks pretty good. There are outliers but overall I am happy with it. It would be a bit more accurate if the prediction was done close to sunrise and also if I had not chimney shadow. In my case prediction is done at 2am since this is when automation kicks in. Automation checks prediction and then deciceds if battery should be charged and also how much.




  • Registered Users Posts: 1,439 ✭✭✭DC999


    Hey. That's a great setup and something very advanced from me at the moment. My panels only due to arrive next week. I don't have a battery but may consider a DIY one once I see how FIT settles and I get comfortable with my setup.

    Can I ask why you'd use the battery at this time of year? Not being critical of you. Just trying to understand for my own solar journey. I guess it's only needed on the days when the solar is less than you need for consumption. I see some 5kwh days.

    Is it to fill up on a very cheap EV rate from something like 2-5am so you don't need to import anything from the grid if you need more power that day?

    I can totally see how useful this is outside the summer months.

    Cheers



  • Moderators, Home & Garden Moderators Posts: 5,964 Mod ✭✭✭✭graememk


    Use the battery when demand (eg kettle, oven etc) is outstripping supply from the panels, And also when its dark.

    Since march hit, I have not been doing any night time charging.



  • Registered Users Posts: 793 ✭✭✭reklamos


    Yes, I do use cheap EV rate to top batteries but only when required. Trying to save as much as I can. :)



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


    There are three scenarios overnight

    1. Discharge the battery charged via solar during the day (going 24hrs day after day on Solar generated power

    2. Discharge during expensive units periods, and stop discharge and use the grid during the cheap period (generally when following day forecast poor during the summer)

    3. Discharge during expensive units periods and use the grid to recharge the battery during the cheap period (generally all winter)



  • Registered Users Posts: 32 scuzzie2k


    Looks good, can I ask how you get all this data, I am trying to see how well mine is working, using My Home Forcast.Solar, the predictions are well off, I have the correct setting in



  • Registered Users Posts: 793 ✭✭✭reklamos


    I use solcast as Forcast.Solar was way off. I still needed to tune it based on observations.



  • Registered Users Posts: 189 ✭✭connesha


    For many people here, incl. myself, the values used for register 43110 are:

    33: Self Use - Stop (charging is off)

    35: Self Use - Run (charge/discharge is on, per your schedule)

    96: Feed In priority mode (Export instead of battery charge)

    To find these, I changed the setting manually on the inverter, and then read the register to see what it was. I haven't seen a value of 49, so can't advise there. Convert the value to binary, and take look at Appendix VII here: https://www.scss.tcd.ie/Brian.Coghlan/Elios4you/RS485_MODBUS-Hybrid-BACoghlan-201811228-1854.pdf. The bit set in yours is not documented. (33 vs 49 in binary)

    Difficult to advise which way you should go... to use the the values I've given above, or figure them out from your own system...



  • Advertisement
  • Registered Users Posts: 2,278 ✭✭✭SD_DRACULA


    The only thing I might be doing differently is that I am using Backup mode for the battery, so I have that set to 15% which will power the backup supply in case of an outage and the lowest battery SOC is set to 10%.

    Might be the reason for the 49 there?

    I will go up and change it to the other settings and see what values comes in then.



Advertisement