Hi Guys,
i am trying to build a nursing-lamp so it is very mission critical so all the code shoudl run on the esp also if the server is not reachable!
I will use a wemos D1 mini pro (external Antenna!) together with a AC-dimmer.
The Function should be on the lamp itself:
rotary encoder: increase/decrease brightness
momentary switch (on encoder): toggle light on/off
PIR: future implementation
same function should be controllable by HA and this is already working
My code looks like this:
esphome:
name: dimmer-stehlampe
esp8266:
board: d1_mini_pro
wifi:
ssid: !secret tech_ssid
password: !secret tech_pw
fast_connect: true
manual_ip:
static_ip: 192.168.30.10
gateway: 192.168.30.1
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphomeapipwd
ota:
password: !secret esphomeotapwd
captive_portal:
output:
- platform: ac_dimmer
gate_pin: D7
init_with_half_cycle: true
id: dimmer1
zero_cross_pin:
number: D6
mode:
input: true
inverted: yes
light:
- platform: monochromatic
output: dimmer1
id: light1
name: stehlampe Dimmer
sensor:
- platform: rotary_encoder
name: "stehlampe Rotary"
pin_a: D1
pin_b: D2
min_value: 0
max_value: 100
filters:
- or:
- debounce: 0.3s
- delta: 2
resolution: 4
on_value:
- light.dim_relative:
id: light1
relative_brightness: 5%
transition_length: 0.02s
binary_sensor: # PIR
- platform: gpio
pin: D5 # PIN for PIR
name: "stehlampe PIR"
device_class: motion
- platform: gpio # momentary on rotary
pin: D0
id: switch1
name: "stehlampe switch"
filters:
- delayed_on: 10ms
on_press:
- light.toggle: light1
the dimmer is not yet attached I wanted to get everything working before the AC is connected ( I am a electrical engineer. so thats not a problem).
The Issuer are right now:
- turning the rotary encoder increases or decreases the steps, but the brightness only increments by my chosen 5% but never decreases
- the momentary switch only once turns off the stehlampe switch (but never on again) nor does it toggle the light1
can you point me in the right direction?
thanks a lot!