Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ESPHome/Home Assitant valve component/entity #11

Open
markbergsma opened this issue May 19, 2024 · 0 comments
Open

Use ESPHome/Home Assitant valve component/entity #11

markbergsma opened this issue May 19, 2024 · 0 comments

Comments

@markbergsma
Copy link

I updated my Open AIR Valve ESPHome code to use the newer valve component to control using a single entity, as opposed to the old two entities. I replaced the old "number" and "cover" blocks by:

valve:
  - platform: template
    name: "Valve"
    id: airvalve
    icon: mdi:valve
    has_position: true
    optimistic: true
    lambda: |-
      if (id(my_stepper).target_position == 0) {
        return VALVE_CLOSED;
      }
      else {
        return id(airvalve).position;
      }
    open_action:
      - stepper.set_target:
          id: my_stepper
          target: 525
    close_action:
      - stepper.set_target:
          id: my_stepper
          target: 0
    position_action:
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda |-
              if (pos <= 0.0) { 
                return 0; 
              } else if(pos >= 1.0) {
                return 525;
              } else if (pos > 0.0 && pos < 1.0) {
                int steps = id(valve_capacity_lookup_table)[pos * 100];
                return steps;
              } else {
                return 0;
              }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant