Guest User

Untitled

a guest
Feb 22nd, 2025
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.36 KB | None | 0 0
  1. alias: QW powerlimit correction
  2. description: ""
  3. triggers:
  4.   - trigger: time_pattern
  5.     minutes: /1
  6. conditions:
  7.   - condition: or
  8.     conditions:
  9.       - condition: state
  10.         entity_id: sensor.qw_mode
  11.         state: buy
  12.         for:
  13.           hours: 0
  14.           minutes: 1
  15.           seconds: 0
  16.       - condition: state
  17.         entity_id: sensor.qw_mode
  18.         state: sell
  19.         for:
  20.           hours: 0
  21.           minutes: 1
  22.           seconds: 0
  23. actions:
  24.   - if:
  25.       - condition: template
  26.         value_template: >-
  27.           {{ (states('sensor.qw_powerlimit')|int -
  28.           states('sensor.battery_power')|int|abs)|abs > 50 }}
  29.     then:
  30.       - if:
  31.           - condition: state
  32.             entity_id: sensor.qw_mode
  33.             state: buy
  34.         then:
  35.           - action: input_number.set_value
  36.             metadata: {}
  37.             data:
  38.               value: |-
  39.                 {{ (
  40.                     [
  41.                       states('input_number.deye_desired_max_grid_charge_current')|int+
  42.                       (
  43.                         (
  44.                           (
  45.                             states('sensor.qw_powerlimit')|int -
  46.                             states('sensor.battery_power')|int|abs
  47.                           )/
  48.                           50
  49.                         )|int
  50.                       )
  51.                       ,240
  52.                     ]
  53.                     |sort
  54.                   )[0]
  55.                 }}
  56.             target:
  57.               entity_id: input_number.deye_desired_max_grid_charge_current
  58.         else:
  59.           - action: input_number.set_value
  60.             metadata: {}
  61.             data:
  62.               value: |-
  63.                 {{ (
  64.                     [
  65.                       states('input_number.deye_desired_max_discharge_current')|int+
  66.                       (
  67.                         (
  68.                           (
  69.                             states('sensor.qw_powerlimit')|int -
  70.                             states('sensor.battery_power')|int|abs
  71.                           )/
  72.                           50
  73.                         )|int
  74.                       )
  75.                       ,240
  76.                     ]
  77.                     |sort
  78.                   )[0]
  79.                 }}
  80.             target:
  81.               entity_id: input_number.deye_desired_max_discharge_current
  82. mode: single
  83.  
Advertisement
Add Comment
Please, Sign In to add comment