Setting Inverter modes using Automations - nathanmarlor/foxess_modbus GitHub Wiki
This integration exposes some inverter controls (Work Mode, Change MinSoc, MaxSoc) that may be modified automatically in Home Assistant to meet certain conditions.
Example - Setting Inverter Work Mode to Feed-in First between certain times of day
For this example a user would like their inverter to automatically change to 'Feed-In First' mode at 9am each day which would let them maximise their export potential on products like Octopus Flux, returning to 'Self Use' at 5pm.
The automation checks first that the work mode isn't already selected to minimise unnecessary writes to the inverter.
To enter the automation by hand follow these instructions, or you can simply copy the code below into a blank automation
In Home Assistant, in the side bar menu click on [Settings, Automations & Scenes], then click the button '(+ Create Automation)' in the lower right corner.
In the Menu click on the item 'Create Blank Automation'
Click 'Add Trigger' and from the drop down list select 'Time'
Enter the time you want the action to occur "09:00:00" then click 'Add Trigger' and again select 'Time' from the drop down list, this time enter the ending time "17:00:00"
At the bottom of the screen, under Actions select (+ Add Action)
Choose 'If-Then' from the list
Under the 'If*:' select (+ Add Condition), choose 'Time' from the list
In the 'Before' section, set the time to be "04:59:00 PM" [This will be the time 'before' which this action will pass]
In the 'Then*:' section underneath, select (+ Add Action), choose 'If-Then' again from the list
Under the 'If*:' select (+ Add Condition), choose 'State' from the list
In the Entity box enter 'Work Mode' and choose the entity it gives.
Click on the 'State' box and choose 'Self Use'
In the 'Then*:' section underneath, select (+ Add Action), choose 'Call Service' from the list
In the Service name enter 'Select: Select' and choose that option in the list
then click on the green '+ Choose Entity' button and choose 'Work Mode'
Click in the 'Option' box and choose 'Feed-in First'
At the very bottom of the screen click where it says 'Add else:'
Click '+ ADD ACTION' and select 'If-Then' from the list
Under the 'If*:' select (+ Add Condition), choose 'State' from the list
In the Entity box enter 'Work Mode' and choose the entity it gives.
Click on the 'State' box and choose 'Feed-in First'
In the 'Then*:' section underneath, select (+ Add Action), choose 'Call Service' from the list
In the Service name enter 'Select: Select' and choose that option in the list
then click on the green '+ Choose Entity' button and choose 'Work Mode'
Click in the 'Option' box and choose 'Self Use'
Click SAVE in the bottom right corner, give it a name 'Work Mode Change' and enter a description 'This automation changes the inverter work mode to feed in first at 9am and back to self use at 5pm'
The YAML code would look like this
alias: Work Mode Change
description: "This automation changes the inverter work mode to feed in first at 9am and back to self use at 5pm"
trigger:
- platform: time
at: "09:00:00"
- platform: time
at: "17:00:00"
condition: []
action:
- if:
- condition: time
after: "00:00:00"
before: "16:59:59"
then:
- if:
- condition: state
entity_id: select.work_mode
state: Self Use
then:
- service: select.select_option
data:
option: Feed-in First
target:
entity_id: select.work_mode
else:
- if:
- condition: state
entity_id: select.work_mode
state: Feed-in First
then:
- service: select.select_option
data:
option: Self Use
target:
entity_id: select.work_mode
mode: single