Update PD-Stepper-Position-Control.yaml

suppress aggressive encoder polling
This commit is contained in:
C H R I S T I A N 2025-02-11 18:57:27 +01:00 committed by GitHub
parent 802cd5c2e8
commit 06f76f04a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -178,9 +178,10 @@ sensor:
name: Encoder name: Encoder
id: encoder id: encoder
update_interval: 0s # beware of the polling rate update_interval: 0s # beware of the polling rate
internal: true # don't publish sensor data to Home Assistant or web server
filters: filters:
- delta: 2 - delta: 2 # throttle the high polling rate to only act on value changes
# filter which computes absolute position from angle value # compute absolute position from angle value
- lambda: | - lambda: |
const uint16_t curr = x; //current encoder value 0-4095 const uint16_t curr = x; //current encoder value 0-4095
const uint16_t prev = id(encoder_tracking_)[0]; //previous encoder value 0-4095 const uint16_t prev = id(encoder_tracking_)[0]; //previous encoder value 0-4095
@ -193,6 +194,8 @@ sensor:
} }
id(encoder_tracking_)[0] = curr; id(encoder_tracking_)[0] = curr;
return id(encoder_tracking_)[1]; return id(encoder_tracking_)[1];
- multiply: -1.0
- throttle: 100ms # limit the amount of new sensor states from this component
accuracy_decimals: 0 accuracy_decimals: 0
state_class: measurement state_class: measurement