springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
129 stars 44 forks source link

Solis inverter via Solis Cloud - getting 'NoneType' object has no attribute 'split' #1375

Open chris-y opened 3 months ago

chris-y commented 3 months ago

Describe the bug I'm trying to set up predbat for my Solis inverter but using Solis Cloud rather than modbus. Monitoring is working great, but I'm not able to do any control. If I test any control service nothing happens, and I'm seeing 'NoneType' object has no attribute 'split' in the log and status.

I have set read-only to off and set a forced charge, then waited for the start of the forced charge to see if the charge_start_service triggers - it doesn't - and the only thing which looks relevant in the log is this NoneType error.

Expected behavior I expect my service to be called.

Predbat version

1.1.8

Environment details

Screenshots image image

Log file

    self.set_current_from_power(direction, 0)
  File "/config/inverter.py", line 1789, in set_current_from_power
    self.write_and_poll_value(f"timed_{direction}_current", self.base.get_arg(f"timed_{direction}_current", indirect=False, index=self.id), new_current, fuzzy=1)
  File "/config/inverter.py", line 1233, in write_and_poll_value
    domain, entity_name = entity_id.split(".")
AttributeError: 'NoneType' object has no attribute 'split'

Config

The charge_start_service stuff is what I was trying out. The first one runs a script which has 'power' as an input and just notifies me. This never triggers. The second runs the pyscript which controls the inverter, but I'll probably set this up as a script which takes the parameters to get the config out of here. For now though I was just trying to get it to trigger anything.

pred_bat:
  module: predbat
  class: PredBat

  # Sets the prefix for all created entities in HA - only change if you want to run more than once instance
  prefix: predbat

  # XXX: This is a configuration template, delete this line once you edit your configuration
  #template: True

  # If you are using Predbat outside of HA then set the HA URL and Key (long lived access token here)
  #ha_url: 'http://homeassistant.local:8123'
  #ha_key: 'xxx'

  # Timezone to work in
  timezone: Europe/London

  #
  # Sensors, currently more than one can be specified and they will be summed up automatically
  # however if you have two inverters only set one of them as they will both read the same.
  #

  inverter_type: MINE
  inverter:
    name: "Solis Inverter"
    has_rest_api: False
    has_mqtt_api: False
    has_service_api: True
    output_charge_control: "current"
    current_dp: 0
    has_charge_enable_time: False
    has_discharge_enable_time: False
    has_target_soc: False
    has_reserve_soc: False
    charge_time_format: "HH:MM"
    charge_time_entity_is_option: False
    soc_units: "%"
    num_load_entities: 1
    has_ge_inverter_mode: False
    time_button_press: False
    clock_time_format: "%Y-%m-%d %H:%M:%S"
    write_and_poll_sleep: 2
    has_time_window: False
    support_charge_freeze: False
    support_discharge_freeze: False
    can_span_midnight: False
    charge_control_immediate: True

    charge_start_service:
      - service: script.test_script
        power: {power}

      - service: pyscript.solis_control
        data:
          days:
            - chargeCurrent: "{power}"
              dischargeCurrent: "0"
              chargeStartTime: "{charge_start_time}"
              chargeEndTime: "{charge_end_time}"
              dischargeStartTime: "00:00"
              dischargeEndTime: "00:00"
            - chargeCurrent: "{power}"
              dischargeCurrent: "0"
              chargeStartTime: "00:00"
              chargeEndTime: "00:00"
              dischargeStartTime: "00:00"
              dischargeEndTime: "00:00"
            - chargeCurrent: "{power}"
              dischargeCurrent: "0"
              chargeStartTime: "00:00"
              chargeEndTime: "00:00"
              dischargeStartTime: "00:00"
              dischargeEndTime: "00:00"
          config:
            secret: xxxx
            key_id: xxxx
            username: xxxx
            password: xxxx
            plantId: xxxx

  #solax_modbus_new: True   # Set to True if you have integration version 2024.03.2 or beyond

  num_inverters: 1
  #
  # Controls/status - must by 1 per inverter
  #

  # Max inverter power from battery
  battery_rate_max:
    - 3600
  # Battery capacity in kWh
  soc_max:
    - 9.6

  # Solis specific parameters (these are based on https://github.com/wills106/homeassistant-solax-modbus)

  load_today:
    - sensor.solis_daily_grid_energy_used
  import_today:
    - sensor.solis_daily_grid_energy_purchased
  export_today:
    - sensor.solis_daily_on_grid_energy
  pv_today:
    - sensor.solis_energy_today

  battery_voltage:
    - sensor.solis_battery_voltage

  # This is disabled by default in the Solax integration so it must be manually enabled.
  #inverter_time:
  #  - sensor.solis_rtc

  # This is disabled by default in the Solax integration so it must be manually enabled.
  battery_power:
    - sensor.solis_battery_power
  pv_power:
    - sensor.solis_ac_output_total_power

  # For Solis inverters we need to add the bypass (backup) load to the main house load. If not used the load_power_1 can be commented out
  load_power:
    - sensor.solis_plant_total_consumption_power
  #load_power_1:
  #  - sensor.solis_backup_load_power

  soc_percent:
    - sensor.solis_remaining_battery_capacity

  reserve:
    - sensor.solis_force_discharge_soc

  battery_min_soc:
    - sensor.solis_force_discharge_soc

  # Inverter max AC limit (one per inverter)
  # If you have a second inverter for PV only please add the two values together
  inverter_limit: 3600

  # Export limit is a software limit set on your inverter that prevents exporting above a given level
  # When enabled Predbat will model this limit
  #export_limit:
  #  - 3600
  #  - 3600
  #
  # The maximum rate the inverter can charge and discharge the battery can be overwritten, this will change
  # the register programming and thus cap the max rates. The default is to use the maximum supported rates (recommended)
  #
  inverter_limit_charge:
    - 3500
  inverter_limit_discharge:
    - 3500

  # Set these to match solcast sensor names if not using the cloud interface
  # The regular expression (re:) makes the solcast bit optional
  # If these don't match find your own names in Home Assistant
  pv_forecast_today: re:(sensor.(solcast_|)(pv_forecast_|)forecast_today)
  pv_forecast_tomorrow: re:(sensor.(solcast_|)(pv_forecast_|)forecast_tomorrow)
  pv_forecast_d3: re:(sensor.(solcast_|)(pv_forecast_|)forecast_(day_3|d3))
  pv_forecast_d4: re:(sensor.(solcast_|)(pv_forecast_|)forecast_(day_4|d4))

  # car_charging_energy defines an incrementing sensor which measures the charge added to your car
  # is used for car_charging_hold feature to filter out car charging from the previous load data
  # Automatically set to detect Wallbox and Zappi, if it doesn't match manually enter your sensor name
  # Also adjust car_charging_energy_scale if it's not in kwH to fix the units
  # car_charging_energy: 're:(sensor.myenergi_zappi_[0-9a-z]+_charge_added_session|sensor.wallbox_portal_added_energy)'

  num_cars: 1
  car_charging_now: binary_sensor.xxnnxxx_charging

   # To make planned car charging more accurate, either using car_charging_planned or Octopus Intelligent
  # specify your battery size in kwh, charge limit % and current car battery soc % sensors/values
  # If you have intelligent the battery size and limit will be extracted from Intelligent directly
  # Set the car SOC% if you have it to give an accurate forecast of the cars battery levels
  # One entry per car if you have multiple cars
  car_charging_battery_size:
    - 52
  # car_charging_limit:
  #   - 're:number.tsunami_charge_limit'
  car_charging_soc:
    - sensor.xxnnxxx_battery

  # Energy rates
  # Please set one of these three, if multiple are set then Octopus is used first, second rates_import/rates_export and latest basic metric

  # Set import and export entity to point to the Octopus Energy plugin
  # automatically matches your meter number assuming you have only one
  # Will be ignored if you don't have the sensor
  # Or manually set it to the correct sensor names e.g:
  # sensor.octopus_energy_electricity_xxxxxxxxxx_xxxxxxxxxxxxx_current_rate
  # sensor.octopus_energy_electricity_xxxxxxxxxx_xxxxxxxxxxxxx_export_current_rate
  metric_octopus_import: 're:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_current_rate)'
  metric_octopus_export: 're:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_export_current_rate)'

  # Standing charge can be set to a sensor (e.g. Octopus) or manually entered in pounds here (e.g. 0.50 is 50p)
  metric_standing_charge: 're:(sensor.(octopus_energy_|)electricity_[0-9a-z]+_[0-9a-z]+_current_standing_charge)'

   # Import rates can be overridden with rate_import_override
  # Export rates can be overridden with rate_export_override
  # Use the same format as above, but a date can be included if it just applies for a set day (e.g. Octopus power ups)
  # This will override even the Octopus plugin rates if enabled
  #
  #rates_import_override:
  #  - date: '2023-09-10'
  #    start: '14:00:00'
  #    end: '14:30:00'
  #    rate: 5

  # Carbon Intensity data from National grid
  carbon_intensity: 're:(sensor.carbon_intensity_uk)'

  # Octopus saving session points to the saving session Sensor in the Octopus plugin, when enabled saving sessions will be at the assumed
  # Rate is read automatically from the add-in and converted to pence using the conversion rate below (default is 8)
  octopus_saving_session: 're:(binary_sensor.octopus_energy([0-9a-z_]+|)_saving_session(s|))'
  octopus_saving_session_octopoints_per_penny: 8

  # Watch list, a list of sensors to watch for changes and then update the plan if they change
  # This is useful for things like the Octopus Intelligent Slot sensor so that the plan update as soon as you plugin in
  # Only uncomment the items you actually have set up above in apps.yaml, of course you can add your own as well
  # Note those using +[] are lists that are appended to this list, whereas {} items are single items only
  watch_list:
  #  - '{octopus_intelligent_slot}'
  #  - '{octopus_ready_time}'
  #  - '{octopus_charge_limit}'
    - '{octopus_saving_session}'
  #  - '+[car_charging_planned]'
  #  - '+[car_charging_soc]'
    - '{car_charging_now}'

  # For pv estimate, leave blank for central estimate, or add 10 for 10% curve (worst case) or 90 or 90% curve (best case)
  # If you use 10 then disable pv_metric10_weight below
  # pv_estimate: 10

  # Days previous is the number of days back to find historical load data
  # Recommended is 7 to capture day of the week but 1 can also be used
  # if you have more history you could use 7 and 14 (in a list) but the standard data in HA only lasts 10 days
  days_previous:
    - 7

  # Days previous weight can be used to control the weighting of the previous load points, the values are multiplied by their
  # weights and then divided through by the total weight. E.g. if you used 1 and 0.5 then the first value would have 2/3rd of the weight and the second 1/3rd
  days_previous_weight:
    - 1

  # Number of hours forward to forecast, best left as-is unless you have specific reason
  forecast_hours: 48

  # The number of hours ahead to count in charge planning (for cost estimates)
  # It's best to set this on your charge window repeat cycle (24) but you may want to set it higher for more variable
  # tariffs like Agile
  forecast_plan_hours: 24

  # Specify the devices that notifies are sent to, the default is 'notify' which goes to all
  #notify_devices:
  #  - mobile_app_treforsiphone12_2

  # Set the frequency in minutes that this plugin is run
  # recommend something that divides by 60 (5, 10 or 15) or you won't trigger at the start of energy price slots
  run_every: 5

  # Battery scaling makes the battery smaller (e.g. 0.9) or bigger than its reported
  # If you have an 80% DoD battery that falsely reports it's kwh then set it to 0.8 to report the real figures
  battery_scaling: 1.0

  # Can be used to scale import and export data, used for workarounds
  import_export_scaling: 1.0

  # Export triggers:
  # For each trigger give a name, the minutes of export needed and the energy required in that time
  # Multiple triggers can be set at once so in total you could use too much energy if all run
  # Creates an entity called 'binary_sensor.predbat_export_trigger_<name>' which will be turned On when the condition is valid
  # connect this to your automation to start whatever you want to trigger
  export_triggers:
    - name: 'large'
      minutes: 60
      energy: 1.0
    - name: 'small'
      minutes: 15
      energy: 0.25

  # If you have a sensor that gives the energy consumed by your solar diverter then add it here
  # this will make the predictions more accurate. It should be an incrementing sensor, it can reset at midnight or not
  # It's assumed to be in Kwh but scaling can be applied if need be
  #iboost_energy_today: 'sensor.xxxxx'
  #iboost_energy_scaling: 1.0
springfall2008 commented 2 months ago

You appear to be missing settings for charge/discharge current as below:

timed_charge_current:

chris-y commented 2 months ago

Is that literally what I need? Or do I need a helper or value or something to plug into it?

(Edited, see below)

chris-y commented 2 months ago

OK, I worked that out - I needed a helper created, and this then pokes the value into that. Discharge always seems to be 0, even when I set a forced discharge, is this correct?

I also worked out why my service wasn't called - I'd set it at the wrong level.

Question: Is the {power} always in watts? Is there a way of getting this in amps? Do I just use the current helper I specified in timed_charge_current?

springfall2008 commented 2 months ago

These are in AMPS (current) rather than watts. The timed_discharge_current should not be zero during discharge.

chris-y commented 2 months ago

OK, cool. My discharge current isn't changing from 0, even when I did a test forced discharge.

Screenshot_20240822-192654~2.png

Other than that I think I've got everything working.

chris-y commented 2 months ago

I tried a live test last night, it was supposed to charge the battery a little but when I woke up it had charged to 100%. It then had planned a discharge but the discharge start/end time hadn't been set. I fixed that by setting charge_discharge_with_rate: False.

So I think the only outstanding issue is that neither the charge/discharge rate in Watts or Amps is changing. image image

The charge rate is a bit weird as it looks like it did change overnight yesterday, but not last night: image

Current plan: (we're currently discharging but the rate on the amps sensor is still 0) image

chris-y commented 2 months ago

Further update. The charging current is now updating - not sure what I changed to kick it into action! Discharge current is still stuck on 0.

However, it looks like the charge_start_service etc aren't called after the rate changes, so the rate sent to the inverter is prior to the change. I observed this earlier when it was in charge mode, and now it's gone to hold but hasn't updated with 0A:

Plan is on HOLD: image

Charge rate has dropped to 0A: image

The last call of the service has happened before the drop: (this screenshot taken after the two above) image

Also I notice there's a 1 minute overlap on the discharge stop and charge start times.

It updated about five minutes later but seems a bit of a lag?

After this hold session ended, it updated for the overnight charge: image

The charge rate is still 0A even though it expects to charge a bit: image

Later... OK, it set the correct charge rate a few seconds after the charge period started. It would be better if it set this ahead of time. It seems to call the service very often even if there are no changes - tweaking the current at this point would make sense (in case we lose connection, it's all planned to the most recent prediction before the connection was lost)

chris-y commented 2 months ago

OK, as far as I'm concerned this is working bar a niggle with the charge and discharge currents - which I'll raise as a separate issue.

My config is as follows:

script.set_solis_inverter_config_predbat is:

alias: Set Solis Inverter Config (Predbat)
sequence:
  - metadata: {}
    data:
      days:
        - chargeCurrent: "  0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: >-
            {{ states('sensor.predbat_mine_0_charge_start_time')[0:5] | string
            }}
          chargeEndTime: "{{ states('sensor.predbat_mine_0_charge_end_time')[0:5] | string }}"
          dischargeStartTime: >-
            {{ states('sensor.predbat_mine_0_discharge_start_time')[0:5] |
            string }}
          dischargeEndTime: >-
            {{ states('sensor.predbat_mine_0_discharge_end_time')[0:5] | string
            }}
        - chargeCurrent: " 0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
        - chargeCurrent: " 0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
      config:
        secret: xxxx
        key_id: xxxx
        username: xxxx
        password: xxxx
        plantId: xxxx
    action: pyscript.solis_control
fields: {}
mode: single
icon: mdi:home-battery
description: ""

apps.yaml.txt

eddysteurs commented 2 weeks ago

Chris-y : I managed to get my predbat also working with soliscloud but it seems to call the STOP CHARGE service every 5 minutes and as such sending a command to the inverter (while not needed as there is no status change), do you have this aswell?

chris-y commented 2 weeks ago

Yes, both the start and stop are called every five minutes (sometimes twice) depending on whether it is active or not. I'm not sure how to stop this, might be a Predbat bug?

eddysteurs commented 2 weeks ago

I have requested a predbat update for this , tested it and it seems to work, will come in 8.5.4 version

Fayrewood commented 2 weeks ago

Hi @eddysteurs and @chris-y ,

Could you help me out please?

I am getting an error in HA when creating a simple script based on Eddy's example above of "Message malformed: extra keys not allowed @ data['sequence'][0]['fields']" I've checked indentation etc but can't see the issue. I have gone into HA / Scripts and added a blank script and pasted from Eddy's example and added my API keys and times.

I have Solis Cloud installed and connected to the cloud servers and reporting the inverter information OK and have installed the Solis Control .py file in the pyscripts folder.

I am using a simple set of times to test connectivity for now - can you see what I may be doing wrong? If I use the data and config elements directly in Dev Tools / Call Service, it works for me, but I can't get my head around the yaml for the script.

alias: Set Solis Inverter Config (Predbat)
sequence:
  - metadata: {}
    data:
      days:
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "01:05"
          chargeEndTime: "15:55"
          dischargeStartTime: "16:05"
          dischargeEndTime: "18:55"
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
      config:
        secret: "cc8165edfredacted"
        key_id: "1300386redacted"
        username: "ben@redacted"
        password: "redacted"
        plantId: "redacted"
    action: pyscript.solis_control
fields: {}
mode: single
icon: mdi:home-battery
description: ""

I get the following in the HA Logs if I run the script:

Logger: custom_components.pyscript.function
Source: custom_components/pyscript/function.py:453
integration: Pyscript Python scripting ([documentation](https://github.com/custom-components/pyscript), [issues](https://github.com/custom-components/pyscript/issues))
First occurred: 12:22:22 (7 occurrences)
Last logged: 12:52:03

run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 755, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: solis_control() called with unexpected keyword arguments: data
run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 755, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: solis_control() called with unexpected keyword arguments: action, data, metadata

Many thanks! Pete

eddysteurs commented 2 weeks ago

Hi @eddysteurs and @chris-y ,

Could you help me out please?

I am getting an error in HA when creating a simple script based on Eddy's example above of "Message malformed: extra keys not allowed @ data['sequence'][0]['fields']" I've checked indentation etc but can't see the issue. I have gone into HA / Scripts and added a blank script and pasted from Eddy's example and added my API keys and times.

I have Solis Cloud installed and connected to the cloud servers and reporting the inverter information OK and have installed the Solis Control .py file in the pyscripts folder.

I am using a simple set of times to test connectivity for now - can you see what I may be doing wrong? If I use the data and config elements directly in Dev Tools / Call Service, it works for me, but I can't get my head around the yaml for the script.

alias: Set Solis Inverter Config (Predbat)
sequence:
  - metadata: {}
    data:
      days:
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "01:05"
          chargeEndTime: "15:55"
          dischargeStartTime: "16:05"
          dischargeEndTime: "18:55"
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
        - chargeCurrent: "50"
          dischargeCurrent: "50"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
      config:
        secret: "cc8165edfredacted"
        key_id: "1300386redacted"
        username: "ben@redacted"
        password: "redacted"
        plantId: "redacted"
    action: pyscript.solis_control
fields: {}
mode: single
icon: mdi:home-battery
description: ""

I get the following in the HA Logs if I run the script:

Logger: custom_components.pyscript.function
Source: custom_components/pyscript/function.py:453
integration: Pyscript Python scripting ([documentation](https://github.com/custom-components/pyscript), [issues](https://github.com/custom-components/pyscript/issues))
First occurred: 12:22:22 (7 occurrences)
Last logged: 12:52:03

run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 755, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: solis_control() called with unexpected keyword arguments: data
run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 755, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: solis_control() called with unexpected keyword arguments: action, data, metadata

Many thanks! Pete

eddysteurs commented 2 weeks ago

i copied and pasted your script in my HA and i works fine, no errors, created a new SCRIPT , put it in yaml and pasted your content, so I have no clue what the problem is, sorry

chris-y commented 2 weeks ago

Looks OK to me too. Be aware that for your script you need to edit the entire script in yaml, not just the sequence, as you only get part of the yaml then.

Is the pyscript installed correctly? Did you enable the global variables etc that the script requires?

Fayrewood commented 2 weeks ago

Thanks for the prompt responses chaps. Yes, both of the global variables are enabled. Now, that's bloody weird. I copied the code from the script (in yaml mode) and created a new one, and hey presto, it's working!. Thanks!!

Fayrewood commented 1 week ago

@eddysteurs / @chris-y - I have created a Number helper for input_number.solis_battery_charge_rate_predbat but I am getting errors. What helpers did you guys create and were they number or text helpers? Did you have to set an initial value, as mine is currently at zero.

My errors:

ValueError: Template error: int got invalid input 'unknown' when rendering template '0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }}' but no default was specified

and

Set Solis Inverter Config (Predbat): Error executing script. Error for call_service at pos 1: Error rendering data template:
 ValueError: Template error: int got invalid input 'unknown' when rendering template 
'0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }}' 
but no default was specified
PredBat Logs

38171 | 2024-11-04 08:40:09.599798: Error: float() argument must be a string or a real number, not 'NoneType'
-- | --
38170 | 2024-11-04 08:40:09.599304: Info: record_status Error: Exception raised float() argument must be a string or a real number, not 'NoneType'
38168 | TypeError: float() argument must be a string or a real number, not 'NoneType'
38151 | 2024-11-04 08:40:09.561165: Error: Traceback (most recent call last):
38150 | 2024-11-04 08:40:09.560009: Error: Exception raised float() argument must be a string or a real number, not 'NoneType'

Thanks, Pete

eddysteurs commented 1 week ago

Normal number helper image my script image

and in predbat apps.yaml :

charge_start_service:

Fayrewood commented 1 week ago

Thanks @eddysteurs. I'll have a play with the helpers.

I have the same service call for each of the charge & discharge services, following the templates near the top of this thread. I see that you have different service scripts for each. Are they all duplicates of one script, with the same parameters as per your screenshot?

I'm not familiar with Solis inverters, other than trying to get this set up for a friend, but I noticed that your discharge current is "001", which is different from the "80" in @chris-y 's template. Any pointers on what the current should be? It's a 5kw hybrid inverter.

Here's my current apps.yaml.

charge_start_service:
    - service: script.set_solis_inverter_config_predbat
  discharge_start_service:
    - service: script.set_solis_inverter_config_predbat
  charge_stop_service:
    - service: script.set_solis_inverter_config_predbat
  discharge_stop_service:
    - service: script.set_solis_inverter_config_predbat

  timed_charge_current:
    - input_number.solis_battery_charge_rate_predbat
  timed_discharge_current:
    - input_number.solis_battery_discharge_rate_predbat
chris-y commented 1 week ago

My charge and discharge scripts are the same - it has to send all this information at once and if you split them and provide just the charge or just the discharge values it will overwrite the other - so it's easier to keep them as the same script and set both. My "stop" script I'm not sure is necessary, I only added it afterwards to ensure the inverter was stopping when Predbat thought it should, as I was getting weird spikes in current as it stopped. (I might try removing this again and see if that is still happening)

It should be picking the discharge current up from the helper - Predbat will set this for you. It looks like @eddysteurs may have split it into a charge and discharge script but as per above I don't see any need to do that. Mine was hardcoded to 80 as that's the maximum it will export (generally; I think it can do 100A but there's a risk of things tripping apparently, so I set it to 80 to be safe), and the discharge current helper wasn't working correctly at that time. That was fixed so I've since changed it to dischargeCurrent: " 0{{ states('input_number.solis_battery_discharge_rate_predbat') | int | string }} ", and Predbat tends to pick 72A.

This is my STOP script: (the discharge current is still hardcoded on this but it doesn't matter as all the times are zeroed so it isn't doing anything anyway)

alias: Set Solis Inverter Config (Predbat) - STOP
sequence:
  - metadata: {}
    data:
      days:
        - chargeCurrent: "  0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
        - chargeCurrent: " 0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
        - chargeCurrent: " 0{{ states('input_number.solis_battery_charge_rate_predbat') | int | string }} "
          dischargeCurrent: "80"
          chargeStartTime: "00:00"
          chargeEndTime: "00:00"
          dischargeStartTime: "00:00"
          dischargeEndTime: "00:00"
      config:
        secret: xxx
        key_id: xxx
        username: xxx
        password: xxx
        plantId: xxx
    action: pyscript.solis_control
fields: {}
mode: single
icon: mdi:home-battery
description: ""
eddysteurs commented 1 week ago

as such this is not needed, but I do this to include some other stuff (status, messages, warnings,...) which are different for charge , discharge , start and stop. If you dont need this you can call just once script. (I need to include all parameters anyway or the solis control does not work. How do you guys process the charge pause (freeze), because I dont understand how this should be set to the solis inverter because if you read the meaning of this (in predbat) then solis does not support this, I think the closed is to stop discharge and allow the house load to come from the grid. But there is no different service call foreseen and the parameters are charge with 0 amp.

chris-y commented 1 week ago

I naïvely thought that setting:

    support_charge_freeze: False
    support_discharge_freeze: False

would stop it trying to do a charge freeze, or would somehow emulate it (eg. let it discharge until it got to the required SOC, then charge at 0A to stop it falling further)

I think what it has done previously is just stopped it charging or discharging regardless of the current SOC, but I haven't tried forcing one to check.