Pulsecounter counting

i got this pulsecounter , and when i have 520 pulses , i want to to an action via : on_value_range

this is not working

sensor:
  - platform: pulse_counter
    pin: GPIO14
    name: "Pulse Counter"
    id: pulse_counter0
    update_interval: 500ms
    total:
      name: "Total Pulses"
      id: totalpulses
      unit_of_measurement: "pulses"
      accuracy_decimals: 0
    filters:
      - multiply: 1   
    on_value_range: 
      above:   520.0
      below: 530.0
      then:
        - switch.turn_off: cmd_omlaag
        - switch.turn_off: cmd_omhoog
        - delay : 2s
        - pulse_counter.set_total_pulses: 
            id: pulse_counter0
            value: 0          

on the other hand , i have a entity as binary sensor , that has an error inside it , but is works

binary_sensor:
  - platform: template 
    id: gate_open
    name: "GateOpen"  #Condition must consist of key-value mapping! Got None.
    lambda: |-
      if (id(totalpulses).state  >= 520 && id(totalpulses).state <= 550) {
        // Gate is open.
        return true;
      } else {
        // Gate is closed or closing.
        return false;
      }
    on_state: 
      then:
        - switch.turn_off: cmd_omlaag
        - switch.turn_off: cmd_omhoog
        - delay : 2s
        - pulse_counter.set_total_pulses: 
            id: pulse_counter0
            value: 0        

         

what is wisdom to solve this to 1 correct yaml code and working code

i added this sensor , also not working


  - platform: template
    name: "geared motor 1/520"
    id: pulses_divided
    update_interval: 500ms
    unit_of_measurement: "omw"
    accuracy_decimals: 2
    lambda: |-
      return id(totalpulses).state / 520.0;   
    on_value_range:
      - above: 520
        then:
          - switch.toggle: cmd_omlaag
          - logger.log: "hahahaha this wont work"      

 

It looks like you missed a dash in your initial code for the on_value_range.
Try this:

sensor:
  - platform: pulse_counter
    pin: GPIO14
    name: "Pulse Counter"
    id: pulse_counter0
    update_interval: 500ms
    total:
      name: "Total Pulses"
      id: totalpulses
      unit_of_measurement: "pulses"
      accuracy_decimals: 0
    filters:
      - multiply: 1
    on_value_range:
      - above: 520.0
        below: 530.0
        then:
          - switch.turn_off: cmd_omlaag
          - switch.turn_off: cmd_omhoog
          - delay : 2s
          - pulse_counter.set_total_pulses:
              id: pulse_counter0
              value: 0

hello , thanks to take the time to help and make a suggestion ,
the code compiles , but the endresult is the same …
the motor doenst stop at 520-530 pulses.

What controls the motor? The 2 switches? Its hard for anyone to teally help you when you decide people only need to see certain parts of your configuration.

No one can be sure if the problem is with the pulse counter, binary sensor, motor controls/switches, or some other part of your config because, we cant see what all you have going on.

Just post your whole config so people can see exactly whats going on and what entities are interacting with each other or even possibly conflicting with each other.