ESPHome configuration Shelly 1 Plus 0-10V Dimmer

I have a ventilation system which I want to automate with a 0-10V dimmer.

I found this Shelly:
https://www.shelly.com/en/products/shop/shelly-plus-0-10-v-dimmer

And I was wondering if this is supported in Esphome and if anyone has a working config. I can’t seem to find anything on the web unfortunately.

2 Likes

Most shellys work with HA without esphome, although I am not sure about that device. I think it is quite new.

1 Like

I’ve bought a few… I haven’t found any code online, but I’ll try to search for some schematics and then make a esphome config out of it. Have you found something?

Does it work out of the box with home assistant?

Yes, perfectly! Fast and real time :wink:

I just have now bought 70 of them, and I want to configure them automatically with name, ip, WiFi etc… this is why I want to flash them with esphome !

Not sure how esphome helps, but this may help

1 Like

Esphome helps with the command line substitutions, very useful in this case :wink:

Thank you for the link BTW, having the pinout really speeds up everything!!

Did you get this working with esphome, and if so can you share you config?

Yes!
This works by itself as shelly.yaml:

substitutions:
    device_name: shelly-0-10
    room: myhome
esphome:
  name: $device_name
  platformio_options:
    board_build.f_cpu: 160000000L
  area: ${room}
  project:
    name: "my-light"
    version: "1.0.0"
  min_version: 2024.4.0 #just to be sure that everything works

esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_FREERTOS_UNICORE: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_160: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "160"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  ap:
    ssid: "${device_name} Fallback Hotspot"
    password: !secret ap_password

logger:

api:
  encryption:
    key: !secret api_encryption_key

ota:
  password: !secret ota_password

web_server:
  port: 80

output:
  - platform: ledc
    pin: GPIO26
    id: led_output
    inverted: true
    frequency: "1220Hz"
    channel: 0
    min_power: 0.6 #this is because my lamp was off up to >50% of my transformer's 0-10 voltage.
    zero_means_zero: true  #to avoid having the lamp on when at 0% with min power.

# Example usage in a light
light:
  - platform: monochromatic
    output: led_output
    name: "${device_name} Light"
    default_transition_length: 100ms
    restore_mode: ALWAYS_ON
    effects:
      - pulse:
      - strobe:
      - flicker: 
    id: dimmer_out

binary_sensor:
  - platform: gpio
    name: "${device_name} Switch 1"
    pin: GPIO4
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Switch 2"
    pin: GPIO18
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button"
    pin:
      number: GPIO25
      inverted: yes
      mode:
        input: true
        pullup: true
    filters:
      - delayed_on_off: 5ms

sensor:
  - platform: ntc
    sensor: temp_resistance_reading
    name: "${device_name} Temperature"
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    icon: "mdi:thermometer"
    calibration:
      b_constant: 3350
      reference_resistance: 10kOhm
      reference_temperature: 298.15K
    on_value_range:
      - above: "80.0"
        then:
          - light.turn_off: dimmer_out
  - platform: resistance
    id: temp_resistance_reading
    sensor: temp_analog_reading
    configuration: DOWNSTREAM
    resistor: 10kOhm
  - platform: adc
    id: temp_analog_reading
    pin: GPIO32
    attenuation: 11db
  - platform: wifi_signal
    name: "${device_name} WiFi Signal"
    update_interval: 60s


status_led:
  pin:
    number: GPIO0
    inverted: true

But if you have many, you can use this template.yaml

substitutions:
  device_name: "DEVICE-NAME" #this is what the script looks for to substitute the name
  room: myhome

<<: !include shelly.yaml

and this script that can be called to generate the configurations and program the chips.

#!/bin/sh
# i needed the devices just to be named numerically, from one number to another, and I could program  them from lower to higher and vice-versa. 
START=184                 # first number to start with
END=170                   # last number
COMMAND=run               # the esphome command you want to execute
MAIN_FILE= shelly.yaml    # the main file
TEMPLATE_FILE=template.yaml   # the template file
TEMPLATE_TOKEN=DEVICE-NAME #how the device name is called in the template, to be overwritten

#########################################
#END OF MANUAL CONFIGS
#########################################
STEP=1
if [ $START -gt $END ]; then  #defines if I have to increment or decrement the number at each step
    STEP=-1
fi

for ((i = $START; i != $END + $STEP; i += $STEP)); do
    if [ "$COMMAND" = "compile" ]; then                    #if esphome "compile", i create the file from template
    	echo esphome -s device_name $i $COMMAND $MAIN_FILE
    	esphome -s device_name $i $COMMAND $MAIN_FILE
        echo sed -e "s/$TEMPLATE_TOKEN/$i/g" $TEMPLATE_FILE > /$i.yaml
        sed -e "s/$TEMPLATE_TOKEN/$i/g" $TEMPLATE_FILE > $i.yaml
    elif [ "$COMMAND" = "upload" ]; then                   #if upload, I just take the generated file and upload it
    	echo esphome  $COMMAND $i.yaml
    	esphome  $COMMAND $i.yaml
    elif [ "$COMMAND" = "run" ]; then      # with run i program them one after the other
    	echo esphome $COMMAND $i.yaml --device $DEVICE --no-logs
	echo -e "\a" #this beeps to let you know you can program a new device
    	read -p "Press enter to continue"
    	esphome $COMMAND $i.yaml --device $DEVICE --no-logs
    fi
done
1 Like

This is amazing, thank you! This might be asking a lot, but can you also add this to the esphome devices site? Contributing: Adding Devices | devices.esphome.io

Yesssss I was planning to, just didn’t find the time to do it yet :slight_smile:

Will do in the next days :wink:

Will be available as soon as the PR is accepted :wink:

1 Like

You rock, thank you!

1 Like