Hi,
I’m working on some project where i use servos to controll hot air distribution.
I got it working but for any automations I need to read the servo position.
I use typical code from manual:
https://esphome.io/components/servo.html
I also have read this topic:
https://community.home-assistant.io/t/servo-motor-wont-work-in-esphome/429297
where DivanX10, managed that, but his code is overingeeniered for me. I don’t need start and end position to setup.
I use full 180 degree movement of servo and I need to reed this possition.
Now I can change servo position by lovelace slider (number function),
but i need some automations where I can check servo position and set it’s position by command or even better in Node Red
This is where i need Your help
AND
In my project I use 4 servos and one relay. Code looks like that:
esphome:
name: dgp-sterownik
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "***************************************************"
ota:
password: "*****************************************************"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Dgp-Sterownik Fallback Hotspot"
password: "**************************"
captive_portal:
servo:
- id: dgp_servo_sypialnia
output: pwm_output_1
transition_length: 1s
- id: dgp_servo_lazienka
output: pwm_output_2
transition_length: 1s
- id: dgp_servo_kuba
output: pwm_output_3
transition_length: 1s
- id: dgp_servo_korytarz
output: pwm_output_4
transition_length: 1s
# Serwa
output:
- platform: esp8266_pwm
id: pwm_output_1
pin: D5
frequency: 50 Hz
- platform: esp8266_pwm
id: pwm_output_2
pin: D6
frequency: 50 Hz
- platform: esp8266_pwm
id: pwm_output_3
pin: D7
frequency: 50 Hz
- platform: esp8266_pwm
id: pwm_output_4
pin: D2
frequency: 50 Hz
number:
- platform: template
name: serwo_sypialnia
min_value: -100
max_value: 100
step: 1
set_action:
then:
- servo.write:
id: dgp_servo_sypialnia
level: !lambda 'return x / 100.0;'
- platform: template
name: serwo_lazienka
min_value: -100
max_value: 100
step: 1
set_action:
then:
- servo.write:
id: dgp_servo_lazienka
level: !lambda 'return x / 100.0;'
- platform: template
name: serwo_kuba
min_value: -100
max_value: 100
step: 1
set_action:
then:
- servo.write:
id: dgp_servo_kuba
level: !lambda 'return x / 100.0;'
- platform: template
name: serwo_korytarz
min_value: -100
max_value: 100
step: 1
set_action:
then:
- servo.write:
id: dgp_servo_korytarz
level: !lambda 'return x / 100.0;'
switch:
- platform: gpio
name: "dgp_dmuchawa"
icon: 'mdi:fan'
id: dgp_dmuchawa
pin:
number: GPIO0 #D3
# # One of INPUT, INPUT_PULLUP or OUTPUT
mode: OUTPUT
inverted: True #stan przekaźnika odpowiada stanowi w HA