Advertisement
CD_Fighter

Automation

Apr 1st, 2024 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.35 KB | Source Code | 0 0
  1. alias: Strom - Nulleinspeisung
  2. description: ""
  3. trigger:
  4.   - platform: state
  5.     entity_id:
  6.      - sensor.shellypro3em_xxx_total_active_power
  7.   - platform: state
  8.     entity_id:
  9.      - sensor.hm_400_p_ac
  10.     enabled: false
  11. condition:
  12.   - condition: or
  13.     conditions:
  14.       - condition: numeric_state
  15.         entity_id: sensor.shellypro3em_xxx_total_active_power
  16.         above: 50
  17.       - condition: numeric_state
  18.         entity_id: sensor.shellypro3em_xxx_total_active_power
  19.         below: -5
  20. action:
  21.   - service: mqtt.publish
  22.     data:
  23.       qos: 0
  24.       retain: false
  25.       topic: inverter/ctrl/limit/1
  26.       payload_template: >-
  27.         {% set newSolarLimit = 0 %}  {% set minSolarLimit = 0 %}  {% set noLimit
  28.         = 100 %}  {% set curGridUsage =
  29.         states('sensor.shellypro3em_xxx_total_active_power') | int %}
  30.         {% set curSolarProd = states('sensor.hm_400_p_ac') | int %}
  31.  
  32.         {% if curGridUsage >= 400 %}
  33.           {{ noLimit }}
  34.         {% elif curGridUsage >= 0 %}
  35.           {% set newSolarLimit = (curGridUsage + curSolarProd - 20) | int %}
  36.           {% if newSolarLimit <= 0 %}
  37.             {% set newSolarLimit = minSolarLimit %}
  38.             {{ newSolarLimit }}
  39.           {% elif newSolarLimit > minSolarLimit %}
  40.             {{ newSolarLimit | int }}W
  41.           {% endif %}
  42.         {% endif %}
  43. mode: single
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement