Skip to content

Instantly share code, notes, and snippets.

@danielolsson100
Created October 25, 2025 14:21
Show Gist options
  • Select an option

  • Save danielolsson100/16d0154a187bcc64946d85f9e8354f20 to your computer and use it in GitHub Desktop.

Select an option

Save danielolsson100/16d0154a187bcc64946d85f9e8354f20 to your computer and use it in GitHub Desktop.

Revisions

  1. danielolsson100 renamed this gist Oct 25, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. danielolsson100 created this gist Oct 25, 2025.
    181 changes: 181 additions & 0 deletions yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,181 @@
    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