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?
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