Is it possible-ESPhome potentiometer to control different devices?

I’m wondering if it’s possible to hook an ESP home device equipped with a potentiometer to control devices like light dimming, fan speed, thermostats, speaker volume, and other devices that might take variable inputs easier done with a knob.

I’m also wondering if the Phillips hue aurora wireless dimmer switch (I already have this in home assistant) could be used for the same purpose.

It would be great to be able to control multiple devices with a single potentiometer or Aurora, but I’d be fine with having a dedicated knob per device if that’s the best that could happen.

Yes. Sure this is possible. Where exactly is your problem?
Attach the poti to the ADC input (make sure to obey the ADC voltage range of your MCU). Use an Analog To Digital Sensor to transfer the ADC value to HA. In HA create an automation to control whatever you want with the ADC value.

1 Like

Thanks, I’m a noob and have had HA for a matter of weeks. I understand most of what you said. I’m not sure how to expose the potentiometer values to HA yet. You said to use an analog to digital sensor. Can you explain that a bit further?

Did you see this?

And you can combine the ADC sensor with the linear calibration option.

2 Likes

Other idea, use a rotary encoder (same same but different).

They can turn “unlimited” and most of them have even a “push button” integrated on the shaft.

The esphome integration makes it also much easier to work with compares to the adc component:

2 Likes

This sounds like you have never exposed any ESPHome sensor to HA? The process is really simple!
I recommend that you check some Youtube videos about that. There are plenty available.

In a nutshell: You add some sensor in your ESPHome YAML (i.e. the fore-mentioned Analog To Digital Sensor) together with the WiFi Component and the API Component and that’s it. Just compile and upload the code to the MCU.
When HA sees your MCU for the very first time you may have to accept the newly found ESPHome device in HA’s frontend in the section Configuration → Integrations. But you only need to do this once.

Thanks so far. Struggling with the automation part now.

I have a the esp equipped with a rotary encoder and see the change in my dashboard however I’m not sure how to pass the value to a light to dim or brighten it when the encoder changes value. Under the “Actions”, is there something I’m missing. I feel like I should see a way to pass in my rotary encoder value.

Not an automation expert (as I do all this in Node Red) but this should work:
Set action to “Call service”, service to “Light: turn on”, add your target entity, switch to YAML mode (three dot menu) and add a data_template: block that sets the brightness: data parameter with a template that references the state of your rotary switch entity.

Should be something like:

action:
  service: light.turn_on
  entity_id: light.office_light
  data_template:
    brightness: >
      {{ states('sensor.rotary_encoder_3')|int }}

Also see this posting:

A little futher, still on the automation.

So this automation seems to trigger only when I pass the “0” and “100” thresholds. It doesn’t trigger continuosly. Seems like I should find a value change trigger?

What I have so far:

description: ''
trigger:
  - type: value
    platform: device
    device_id: 5685ed64cdeb6b9181c03e4a330101b4
    entity_id: sensor.rotary_encoder_3
    domain: sensor
    id: sensor.rotary_encoder_3
    above: 0
    below: 100
condition: []
action:
  - service: notify.notify
    data:
      message: value changed
  - data_template:
      brightness: '{{states(''sensor.rotary_encoder_3'')|int }}'
    entity_id: light.round
    service: light.turn_on
mode: parallel
max: 10

Not even a thank you. Just the next request for help.
Very rude.

Ah sorry, I am actual very grateful for the help so far. I am learning from the forum and respect your time and contribution here.

Got this going with @Jpsy and @tom_l 's help. Thanks, working well with a WemosEsp $3 and a rotary encoder $2. Need to come up with an enclosure…

YAML:

alias: Small Volume Knob
description: ''
trigger:
  - platform: state
    entity_id: sensor.rotary_encoder5
    id: sensor.rotary_encoder5
condition: []
action:
  - service: media_player.volume_set
    target:
      device_id: 5a3838ba2c012cf630bbddda0b307ee8
    data:
      volume_level: '{{ ( states(''sensor.rotary_encoder5'')|float(0) * 0.01 )|round(2) }}'
mode: parallel
max: 10

ESPHome YAML:

esphome:
  name: small-esp
  platform: ESP8266
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "ef4dbb1586c342eaf9512a110bf94e42"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.3.153
    gateway: 192.168.3.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Small-Esp Fallback Hotspot"
    password: "SqioPkLZTB80"

captive_portal:
      
sensor:
  - platform: rotary_encoder
    name: "Rotary_Encoder5"
    pin_a: GPIO5
    pin_b: GPIO4
    
switch:
  - platform: gpio
    pin: GPIO2
    name: "High"
    restore_mode: RESTORE_DEFAULT_ON


image

2 Likes

Very nice compact :pinching_hand: build :+1:
Are you powering the encoder (+) from pin D4 on your d1 mini? :thinking:

yes.

have to type at least 10 characters to post.

nice :wink: