Thanks. The log gave me the clue on how to fix it.
However, now I’ve added a previously working automation in, I’m getting multiple duplicate and bad indentation errors on that automation which won’t rectify with the usual ’ -’ and pairs of spaces. Is there a way to cancel these errors?
description: Set charge periods
mode: single
trigger:
Thanks. Each automation was created using the visual editor and both work if installed separately. The lower ‘stop battery discharging’ automation has had my attempts to fix the duplicate and indentation issues inflicted on it!
Is it possible to create the two of them in one single file using the visual editor? Once I had created the first I couldn’t see how to set up the trigger for the second.
Mangled because I had been trying to get it to work and posted it having forgotten what I had done. Apologies for that and for wasting your time!
I’ve posted the two automations below exactly as they were (separately) created in the Automation Editor. Both run successfully when installed separately but fail when installed together.
As you have seen, I’ve tried to remedy the duplication and indentation errors as they’re reported when I import them into /homeassistant/automations.yaml but whatever I try, especially with indentations, the errors seem to be insoluble.
Your continued help, please, would be invaluable.
description: "Stop battery discharging"
id: "Stop battery discharging"
mode: single
trigger:
- platform: state
entity_id:
- sensor.myenergi_zappi_1609XXXX_plug_status
condition: []
action:
- if:
- condition: state
entity_id: sensor.myenergi_zappi_1609XXXX_plug_status
state: "Charging"
then:
- device_id: 0fb69d3db5c0647101222c026b62XXXX
domain: number
entity_id: d48db2d924c3f48d60731452ea97XXXX
type: set_value
value: 0
else:
- condition: not
conditions:
- condition: state
entity_id: sensor.myenergi_zappi_1609XXXX_plug_status
state: "Charging"
- device_id: 0fb69d3db5c0647101222c026b62XXXX
domain: number
entity_id: d48db2d924c3f48d60731452ea97XXXX
type: set_value
value: 35
alias: "Stop battery discharging"
description: Set periods
mode: single
trigger:
- type: not_powered
platform: device
device_id: 0fb69d3db5c0647101222c026b62XXXX
entity_id: 7e2ac4461ff52513b6ad7c830ea0XXXX
domain: binary_sensor
condition:
- condition: time
after: "23:25:00"
action:
- service: foxess_modbus.update_charge_period
data:
enable_force_charge: true
enable_charge_from_grid: true
start: "23:31:00"
end: "23:59:00"
inverter: 0fb69d3db5c0647101222c026b62XXXX
charge_period: "1"
- service: foxess_modbus.update_charge_period
data:
enable_force_charge: true
enable_charge_from_grid: true
start: "00:01:00"
end: "05:29:00"
inverter: 0fb69d3db5c0647101222c026b62XXXX
charge_period: "2"
alias: Set periods
As you may have noticed this is all very new to me.! I get the Response error 500 every time I try to save an automation, even the very simplest. The ones I copied across after changing from Visual editor to Yaml worked immediately so I’m at a loss to know why they won’t save and why I get the error.
Both work if they’re copied into the Automations yaml separately. If they’re in there together, that’s when they fail. It seems it’s the Response error 500 that’s getting in the way. Are you aware of how to overcome it?
Well the first question to ask is why are you trying to copy them into automations.yaml ? They are automatically saved to automations.yaml when you create them in the editor and save them.
In which case, tell it to save and get the 500 error, then go into the settings > system > logs and paste the logs that are shown so we can get an idea of what the problem is.
I would try stopping Home Assistant, renaming automations.yaml to automations.yaml.bk and then starting Home Assistant again. it’s possible that it’s something already in automations.yaml that is causing the problem.
Yes, stop attempting to import anything into the automation.yaml and use the Automation Editor, in visual mode, to compose your automations from scratch.
I assumed that with HA stopped (how do I stop it to rename the file: I can only see how to shut it down?). I wouldn’t be able to see automations.yaml and would have to SSH into the virtual machine. I’m pretty new to this so am having to learn a lot at a fairly fast rate.