Sterowanie pompą IBO PWM, wysyłanie stanu do Home Assistant 🤔

Posiadam przerobiona klimę na pompę ciepła pomiędzy wymiennikiem a buforem siedzi pompa obiegowa IBO PWM 25/60, zrobiłem do niej sterowanie wydajnością w espHome i za pomocą modułu esp32. W kodzie siedzą dwa skrypty które uruchamiają się po spełnieniu warunku a sama regulacja następuje na podstawie temperatury gazu wpadającej na wymiennik. Monitoruje także moc wyjściową GZ (górnego źródła czyli to co wychodzi na C.O.) i wyliczam COP w locie, do tej pory pompa miała stały przepływ i za pomocą zamontowanego ciepłomierza wiedziałem jaki jest a za pomocą prostego działania mogłem sobie wyliczyć COP i moc GZ bez problemu. Teraz pojawił się problem taki że przepływ mam zmienny i wyliczenia musza być korygowane w locie, same wyliczenia znajdują się w configuration.yaml .
To co potrzebuję zrobić to wyciągnąć w jakiś sposób stan wypełnienia PWM z esphome lub info w którym “if-ie” się teraz znajduje, w esphome stan pompy podaje w logach.
Jak wyciągnąć takie dane z esphome ?
np. sensor który poda mi stan wypełnienia np. 50% i będzie do odczytu w HA.
z góry dziękuję za pomoc, poniżej konfig z esphome;

captive_portal:

dallas:
  - pin: GPIO14
    update_interval: 5s
    
   
  
sensor:
  - platform: homeassistant
    name: "power"
    id: power
    entity_id: sensor.tasmota_energy_power 
    accuracy_decimals: 1
    
#  - platform: template
#    name: "stan ibo"
#    id: stan_ibo   

  - platform: dallas
    address: 0x2b010de70264ff28
    name: "Zasilanie Gaz"
    id: ZG
    accuracy_decimals: 1

  - platform: dallas
    address: 0x26893ae70264ff28                                
    name: "Powrot Ciecz"
    accuracy_decimals: 1
    
  - platform: dallas
    address:  0x5d55161e0264ff28
    name: "Zasilanie C.O." 
    id: TZ
    accuracy_decimals: 1
    filters:
      - calibrate_linear:
           # Map 0.0 (from sensor) to 0.0 (true value)
          - 0.0 -> 0.0
          - 50.0 -> 51.0
          - 35.0 -> 35.0
          - 30.0 -> 30.0
    
  - platform: dallas
    address: 0x48496c190264ff28 
    name: "Powrot C.O."  
    id: TP
    accuracy_decimals: 1
    
script:
  - id: stop_ibo
    then:
      - output.turn_on: IBO_PWM
      - output.set_level:
         id: IBO_PWM
         level: 2%
      - logger.log: "Set IBO Sleep" 
      
  - id: mod_ibo
    then:
      - if:
          condition:
            sensor.in_range:    
              id: ZG
              above: 10
              below: 25
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 2%
            - logger.log: Set IBO level 2 below 25C
      - if:
          condition:
            sensor.in_range:    
              id: ZG
              above: 28.0
              below: 30.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 15%   
            - logger.log: "Set IBO level 15 above 28C"   
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 30.0
              below: 32.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 25%
            - logger.log: "Set IBO level 25 above 30C"    
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 32.0
              below: 34.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 30%  
            - logger.log: "Set IBO level 30 above 32C"  
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 34.0
              below: 36.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 40%    
            - logger.log: "Set IBO level 40 above 34C"  
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 36.0
              below: 38.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 50%  
            - logger.log: "Set IBO level 50 above 36C"  
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 38.0
              below: 40.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 55%  
            - logger.log: "Set IBO level 55 above 38C" 
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 40.0
              below: 42.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 57%  
            - logger.log: "Set IBO level 57 above 40C"
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 42.0
              below: 44.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 59%  
            - logger.log: "Set IBO level 59 above 42C" 
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 44.0
              below: 46.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 61%  
            - logger.log: "Set IBO level 61 above 44C" 
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 46.0
              below: 48.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 63%  
            - logger.log: "Set IBO level 63 above 46C" 
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 48.0
              below: 54.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 65%  
            - logger.log: "Set IBO level 65 above 48C"    
      - if:
          condition:
            sensor.in_range:    
              id: ZG            
              above: 54.0
          then: 
            - output.turn_on: IBO_PWM
            - output.set_level:
               id: IBO_PWM
               level: 88% 
            - logger.log: "Set IBO level 85 above 54C"                
interval:
  - interval: 1s
    then:
    - if:
        condition:
          lambda: 'return id(power).state < 80;'
        then:
          - script.execute: stop_ibo
          - script.stop: mod_ibo
  - interval: 1s
    then:
    - if:
        condition:
          lambda: 'return id(power).state > 100;'
        then:          
          - script.execute: mod_ibo
          - script.stop: stop_ibo
output:
  - platform: ledc
    pin: GPIO13
    id: IBO_PWM
    frequency: "1500Hz"
    inverted: true
1 polubienie

Proponuję utworzyć template number który pojawi ci się w HA.

W skrypcie w każdym ,if" dodatkowa akcja number.set

z wartością jaką ustawiasz poziom wypełnienia dla pompy, bo ustawiasz stałą wartość dla poszczególnych zakresów. Ewentualnie z lambdą niech ci zwraca wartość output id: IBO_PWM

1 polubienie

na to nie wpadłem :stuck_out_tongue: potestuje :innocent: