Skip to content

Instantly share code, notes, and snippets.

@danielolsson100
Created October 25, 2025 14:21
Show Gist options
  • Save danielolsson100/16d0154a187bcc64946d85f9e8354f20 to your computer and use it in GitHub Desktop.
Save danielolsson100/16d0154a187bcc64946d85f9e8354f20 to your computer and use it in GitHub Desktop.
automation.yaml
alias: Battery - FMB - Define Export Threshold
description: ""
triggers:
- entity_id:
- sensor.easee_status
trigger: state
- minutes: /15
trigger: time_pattern
- trigger: state
entity_id:
- binary_sensor.solar_energy_low
- trigger: state
entity_id:
- binary_sensor.bs_ep_low
- trigger: state
entity_id:
- sensor.easee_power
- trigger: state
entity_id:
- sensor.ferroamp_control_status
conditions:
- condition: state
entity_id: sensor.ferroamp_control_status
state: auto
actions:
- if:
- condition: or
conditions:
- condition: state
entity_id: sensor.easee_status
state: charging
enabled: false
- condition: numeric_state
entity_id: sensor.easee_power
above: 1
then:
- action: input_number.set_value
metadata: {}
data:
value: -11000
target:
entity_id: input_number.export_threshold
else:
- if:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.solar_energy_low
state: "on"
- condition: state
entity_id: binary_sensor.bs_ep_low
state: "on"
- condition: state
entity_id: binary_sensor.bs_discharge_ferroamp_battery
state: "on"
then:
- action: input_number.set_value
metadata: {}
data:
value: 0
target:
entity_id: input_number.export_threshold
else:
- action: input_number.set_value
metadata: {}
data:
value: -11000
target:
entity_id: input_number.export_threshold
mode: single
alias: Battery - FMB - Define Import Threshold
description: ""
triggers:
- entity_id:
- sensor.easee_status
trigger: state
- minutes: /15
trigger: time_pattern
- trigger: state
entity_id:
- sensor.easee_power
- trigger: state
entity_id:
- sensor.ferroamp_control_status
conditions:
- condition: state
entity_id: sensor.ferroamp_control_status
state: auto
actions:
- if:
- condition: or
conditions:
- condition: state
entity_id: sensor.easee_status
state: charging
enabled: false
- condition: numeric_state
entity_id: sensor.easee_power
above: 1
then:
- action: input_number.set_value
metadata: {}
data:
value: 11000
target:
entity_id: input_number.import_threshold
else:
- action: input_number.set_value
metadata: {}
data:
value: 0
target:
entity_id: input_number.import_threshold
mode: single
alias: Battery - FMB - Write register
description: ""
triggers:
- trigger: state
entity_id:
- input_number.export_threshold
- trigger: state
entity_id:
- input_number.import_threshold
for:
hours: 0
minutes: 0
seconds: 5
- trigger: state
entity_id:
- sensor.ferroamp_control_status
enabled: false
conditions:
- condition: state
entity_id: sensor.ferroamp_control_status
state: auto
actions:
- action: modbus.write_register
metadata: {}
data:
hub: ferroamp_modbus
address: 8012
slave: 1
value: >
{% set value = states('input_number.export_threshold') | float(0) %} {%
set packed_value = pack(value, ">f") %} {% set high_word =
unpack(packed_value, ">H", offset=2) | abs %} {% set low_word =
unpack(packed_value, ">H") | abs %} [ {{ high_word }}, {{ low_word }} ]
- action: modbus.write_register
metadata: {}
data:
hub: ferroamp_modbus
address: 8002
slave: 1
value: >
{% set value = states('input_number.import_threshold') | float(0) %} {%
set packed_value = pack(value, ">f") %} {% set high_word =
unpack(packed_value, ">H", offset=2) | abs %} {% set low_word =
unpack(packed_value, ">H") | abs %} [ {{ high_word }}, {{ low_word }} ]
- action: modbus.write_register
metadata: {}
data:
hub: ferroamp_modbus
address: 8016
slave: 1
value: 1
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- action: modbus.write_register
metadata: {}
data:
hub: ferroamp_modbus
address: 8006
slave: 1
value: 1
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment