Write support for RCT Power Serial Protocol with rctclient
Important: For safety reasons, there should be no other connections to the inverter (RCT Power App, HA Integration, OpenWB, EVCC etc.)
Also important: This is an experimental tool and therefore not function nor dangerous conditions or damage to the controlled system can be excluded. All risk lies on the owner of the equipment!
Refer also to: rctclient | write support
- Set
power_mng.soc_strategy
to 2 - Set
power_mng.battery_power_external
to the desired charging power (e.g. -6000 = 6 kW) - Wait until SOC target is reached
- Set
power_mng.soc_strategy
to 4 - Set
power_mng.battery_power_extern
to 0
This also prevents excess charging. The battery is therefore not used at all.
- Set
power_mng.soc_strategy
to 2 - Set
power_mng.battery_power_external
to 0 - Wait as long as the car is charging
- Set
power_mng.soc_strategy
to 4
To adjust the available emergency power reserve for the dark season, the value power_mng.soc_min
can be increased. You should then also increase power_mng.soc_charge
in order to recharge from the grid to maintain power_mng.soc_min
.
Increase:
- Set
power_mng.soc_min
to 0.30 (for 30%) - Set
power_mng.soc_charge
to 0.28 (for 28%)
Set to default:
- Set
power_mng.soc_min
to 0.07 (for 7%) - Set
power_mng.soc_charge
to 0.05 (for 5%)
rct.py get <parameter> --host=<ip_address_or_hostname>
rct.py set <parameter> <value> --host=<ip_address_or_hostname>
Valid Parameters:
power_mng.soc_strategy - SOC charging strategy
Valid Values:
0: SOC target = SOC (State of Charge)
1: Konstant (Constant)
2: Extern (External)
3: Mittlere Batteriespannung (Average Battery Voltage)
4: Intern (Internal)
5: Zeitplan (Schedule)
Default Value: 4 (Internal)
power_mng.soc_target_set - Force SOC target
Valid Range: 0.00 to 1.00, with at most two decimal places
Default Value: 0.50
power_mng.battery_power_extern - Battery target power
Valid Range: -6000 to 6000
Positive values indicate discharge, negative values indicate charge
Note: Values will be automatically adjusted to fit within valid ranges.
Default Value: 0
power_mng.soc_min - Min SOC target
Valid Range: 0.00 to 1.00, with at most two decimal places
Default Value: 0.07
power_mng.soc_max - Max SOC target
Valid Range: 0.00 to 1.00, with at most two decimal places
Default Value: 0.97
power_mng.soc_charge_power - Charging power to reach SOC target
Default Value: 100
power_mng.soc_charge - Trigger for charging to SOC_min
Default Value: 0.05
p_rec_lim[1] - Max. battery to grid power
Valid Range: 0 to 6000
Default Value: 0
power_mng.use_grid_power_enable - Enable or disable grid power usage
Valid Values: False or True
Default Value: False
This is an elementary example, how the script could be used within Homeassistant.
- Install pyscript according to the installation instructions from this documentation.
Afterwards, the integration is available: Within the the integration settings, make sure that all imports of all packackes is allowed: Hint: The internal integration "Python Scripts" of Home Assistant is not sufficient, because it is not possible to use Python imports with this integration. Refer to: Home Assistant | Integrations | Python Scripts.
The integration should be ready for use, if basics Pyscript services are provided like this:
First, set up the follwing folders in the config folder of Home Assistant and copy the files "rct.py" and "rct_ha_call.py" from this repository to the folders:
Home Assistant Root Folder:
└── config
└── pyscript
├── modules
│ └── rct.py
└── rct_ha_call.py
within the file rct_ha_call.py
update the default arguments according to your needs:
@service
def rct_ha_call(action='set', parameter='power_mng.soc_max', value=0.97, host='192.168.0.99'):
#"""Using rct.py to set/get parameter of the RCT inverter"""
from rct import get_value, set_value
output = set_value(parameter=parameter, value=value, host=host)
print(output)
log.info(f"rct_ha_call: {output}")
If a default value is provided, less arguments are needed when the service is called from Home Assistant as a service later. In this case, I just want to use to set the parameter of power_mng.soc_max of fixed inverter with IP 192.168.0.99.
Now, the service "rct_ha_call" should be available and the value: 0.97
is the data supplied to the service as the maximum state of charge:
Just my implementation for usage as an example:
input_number.rtc_soc_maximum
is used to provide max. SOC- automation is calling the service, when the input number changes:
alias: Batterie RCT setze SOC Maximum
description: Setzt den den maximalen Speicherwert der Batterie über ein Python-Skript
trigger:
- platform: state
entity_id:
- input_number.rtc_soc_maximum
for:
hours: 0
minutes: 0
seconds: 3
condition: []
action:
- service: pyscript.rct_ha_call
data:
value: "{{states('input_number.rtc_soc_maximum')|multiply(0.01)|round(2)}}"
mode: single
Hint: Do not forget to scale the input number from percentage (i.e. 97%) to fractions (i.e. 0.97) by using the pipeline |multiply(0.01)|round(2)
, as the script expects values from 0...1 as input.
Home Assistant Root Folder:
└── config
├── packages
│ └── rctpower.yaml
└── rct.py
- Copy rct.py to /config/rct.py
- Check configuration.yaml for
homeassistant:
packages: !include_dir_named packages
- Copy packages/rctpower.yaml to /config/packages/rctpower.yaml
- Edit /config/packages/rctpower.yaml and change the IP to your inverter IP
- Install Home Assistant RCT Power Integration
- Restart HA
Pyscript: Python Scripting for Home Assistant | Documentation