Growatt Inverter Mode Switch

Hi,

I am trying to make this work… and all works except one entity:

@KasperHolchKragelund what can be the reason for this?!

Also, if I understand correctly, once other modes disabled, it revers back to load first mode?
p.s. I cannot also load setting for the server, looks like… or nothing I change are seen on the Growatt server

Hi,

@snu-snu-snu I just tried this and I have the same error as you, have you found a solution?

@Snux , could you please share your automation details, I might be configuring something similar.

I also hope that Solar Assistant would be implementing these commands soon and we can skip the Growatt cloud and control directly thru the RS485.

This might be a bug in the example. Hopefully this fixes it for you.

There are 2 buttons in the config.yaml file - see the image above. Adjust the lovelace card to use these names instead (and remove the one not working)

Sorry for my lack of understanding, could you please clarify a bit more what and where to make these changes?
Below is my code from the dashboard, and attached screenshot of the dashboard

views:
  - title: Growatt
    cards:
      - type: entities
        entities:
          - entity: input_boolean.adgw_export_limit_on
          - type: divider
          - entity: input_select.adgw_battery_charge_max_soc
          - entity: input_boolean.adgw_ac_charge_on
          - entity: input_datetime.adgw_battery_first_time_slot_1_start
          - entity: input_datetime.adgw_battery_first_time_slot_1_end
          - entity: input_boolean.adgw_battery_first_time_slot_1_enabled
          - type: divider
          - entity: input_select.adgw_grid_discharge_stopped_soc
          - entity: input_datetime.adgw_grid_first_time_slot_1_start
          - entity: input_datetime.adgw_grid_first_time_slot_1_end
          - entity: input_boolean.adgw_grid_first_time_slot_1_enabled
          - type: divider
          - entity: input_button.adgw_get_charge_settings_button
          - entity: input_button.adgw_set_charge_settings_button
          - entity: sensor.template_adgw_api_state
        title: Inverter settings
        show_header_toggle: false
  - entity: input_boolean.adgw_export_limit_on
  - type: divider
  - entity: input_select.adgw_battery_charge_max_soc
  - entity: input_boolean.adgw_ac_charge_on
  - entity: input_datetime.adgw_battery_first_time_slot_1_start
  - entity: input_datetime.adgw_battery_first_time_slot_1_end
  - entity: input_boolean.adgw_battery_first_time_slot_1_enabled
  - type: divider
  - entity: input_select.adgw_grid_discharge_stopped_soc
  - entity: input_datetime.adgw_grid_first_time_slot_1_start
  - entity: input_datetime.adgw_grid_first_time_slot_1_end
  - entity: input_boolean.adgw_grid_first_time_slot_1_enabled
  - type: divider
  - entity: input_button.adgw_get_charge_settings_button
  - entity: input_button.adgw_set_charge_settings_button
  - entity: sensor.template_adgw_api_state
title: Inverter settings
show_header_toggle: false

I looked at the github repo -

the missing entity is no longer used.

type: entities
entities:
  - entity: input_boolean.adgw_export_limit_on
  - entity: input_button.adgw_set_charge_settings_button_export
  - type: divider
  - entity: input_select.adgw_battery_charge_max_soc
  - entity: input_boolean.adgw_ac_charge_on
  - entity: input_datetime.adgw_battery_first_time_slot_1_start
  - entity: input_datetime.adgw_battery_first_time_slot_1_end
  - entity: input_boolean.adgw_battery_first_time_slot_1_enabled
  - entity: input_button.adgw_set_charge_settings_button_battery_first
  - type: divider
  - entity: input_select.adgw_grid_discharge_stopped_soc
  - entity: input_select.adgw_grid_discharge_power
  - entity: input_datetime.adgw_grid_first_time_slot_1_start
  - entity: input_datetime.adgw_grid_first_time_slot_1_end
  - entity: input_boolean.adgw_grid_first_time_slot_1_enabled
  - entity: input_button.adgw_set_charge_settings_button_grid_first
  - type: divider
  - entity: input_button.adgw_get_charge_settings_button
  - entity: sensor.template_adgw_api_state
title: Inverter settings
show_header_toggle: false

I wonder if anyone here has experience with automation of Intelligent Octopus and inverter??

I am trying to write script where binary sensor is set to ON as trigger - then Growatt is set to battery first.
Once the same sensor is set to OFF - then Battery First is disabled.

trigger:
  - type: turned_on
    platform: device
    device_id: 
    entity_id: binary_sensor.octopus_intelligent_slot
    domain: binary_sensor
condition: []
action: []
action:
  - service: script.battery_first_time_slot_1_enabled
    data: {}
mode: single

would this work as I want to?

any assistance would be appreciated

p.s. also I have a strange bug where I create new automation - go to YAML editor - copy paste the code… and after hitting save - it looks like automation is saved… but if I leavee editor and get back in - it just shos empty automation. what am I missing?

guys, sorry to be annoying, but can someone assist how to use these entities which I can find as “state entity” in the automations?

I have this Intelligent Octopus (IO) tariff which is a bit flexible:

  • by default off-peak super low rate is provided between 23:30 and 5:30
  • however sometimes these super cheap tariffs can be allocated at different times, i.e. 22:00-23:00 and then the standard slot as above.

I want to create an automation where once the car charging cable is plugged into the car and the Slot is allocated - it switches Growatt to Battery first.

I can create automation for the initial action of IO is set and cable is plugged in


but I struggle to understand what function to use to change the Growatt setting into Battery first.
Then I will need to disable battery first once the IO slot is set to OFF.

@mjdyson could you guide me towards right direction? is there something I do wrong?

Hi,
Sorry for late reply. If you use the Lovelace code from here it should work:

The code from this comment thread is outdated, as I have optimized some bits of it. Hope you get it to work, otherwise please let me know.

I got lovelace working, no worries - I found same as you posted.

However, could you please look at my last reply regariding automation for battery first on/off for specific period?

I got the Lovelace card working but i seem not to be able to connect to Growatt server/cloud.

Tried all combinations in /config/secrets.yaml with inverter device number, data logger and plant name but they all return API status = error Msg 502

What is the reason for API status = error Msg 502 ? I have only an installer account and I’m trying to log in with the installer admin account
works fine in the ShinePhone and on server.growatt

I quickly wrote the code below, that can be added to the script: section of the config.yaml file:

  # script to set battery first, can be called from Automations, eg. when power price is low
  adgw_set_battery_first_on:
    alias: adgw_battery_first_on
    sequence:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.adgw_battery_first_time_slot_1_enabled
      - service: input_button.press
        target:
          entity_id: input_button.adgw_set_charge_settings_button_battery_first
    mode: single
    icon: "mdi:toggle-switch-outline"
  adgw_set_battery_first_off:
    alias: adgw_set_battery_first_off
    sequence:
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.adgw_battery_first_time_slot_1_enabled
      - service: input_button.press
        target:
          entity_id: input_button.adgw_set_charge_settings_button_battery_first
    mode: single
    icon: "mdi:toggle-switch-outline"

I have not tested it, but it’s very similar to the export limit service that I’m using to stop exports when price drops very low.

Please let me know if it works as intended and I’ll update the config.yaml on Github as well.

Awesome!
created, edited name (by the way - got error then realised that needed to cut your code in half :smiley:

Nevertheless, I will try tonight once the IO is enabled! :slight_smile: and will post an update!

p.s. automation check/confirmation might happen some time later (in few days) as the on-peak IO slot allocation happen sporadically and cannot predict… :slight_smile:

@KasperHolchKragelund great code you wrote. I use it to control my SPH inverter to. really nice.

The only thing missing for me is the Charge Power Rate when enabeling battery first mode. Its always going to 100% and I want it to be lower.

As far as you know, is there any API limitation why you did not add it? Or diddnt you needed it? I want to try adding it, but not such a Python hero as you are :slight_smile:

Well, think I figured out that its hardcoded to 100%, so I think I can answer my own questions :slight_smile:

@KasperHolchKragelund I managed to get it working for me. I wrote my changes to github and created a pull request. My first one actually. feels like it could have been in one pull request, but I really dont know how to add all three files in it.

Just as reply:

Battery First for Growatt works with your script - I got the automation running. However I cannot confirm if it will work 100% if one-off Intelligent slots. will update later.

but automation with Battery First script worked! Thank you @KasperHolchKragelund

@Jasperw I merged your changes and also added reading the charge power parameter, otherwise it would always show 0 after getting parameters. Thanks for the input on adding charge power.

1 Like

Great @snu-snu-snu I have included the battery first on/off services in v.04 on GitHub. You can set the time and other parameters for battery first in the fields from Lovelace (can be scripted) and it will save all battery first parameters when calling the service.

great. just a question, as I want to understand the whole logic of how it works.

So by default it is 23:30 to 5:30. this is now set as default time to start on and off. these are the manually entered values from the lovelace.

If I am at some point assigned some additonal slots, let’s say at 22:00 to 22:30 (all of them are 30 minute intervals) - will it overwrite the times or it just going to switch into battery mode on without any scheduling?

Currently only one timeslot is used, from the logic that you will always set the next timeslot that’s relevant and thereby overwrite the previous timeslot you used. You can set the date/time via script once you have calculated the best timeslots.
Another method is to have the timeslot always on (00:00 to 23:59) and then just operate the Battery First Enabled switch whenever you want to charge the battery or stop charging. This is might be a simpler solution.

1 Like