Shelly PLUS 1 + ESPHome (+ bletracker)

When esphome-flasher reads the cpu in my shelly plus 1,
Chip Info:

  • Chip Family: ESP32
  • Chip Model: unknown ESP32 (revision 3)
  • Number of Cores: 1
  • Max CPU Frequency: 80MHz
  • Has Bluetooth: YES
  • Has Embedded Flash: YES
  • Has Factory-Calibrated ADC: YES

80MHz not 160MHz, I assume I need to change cpu freq in the setup, or leave default?

For what it may help this works for me:

#https://github.com/esphome-devices/esphome-devices/issues/299
#https://www.esphome-devices.com/devices/Shelly-Plus-1PM

substitutions:
  device_name: "shelly-plus-1pm-01"
  # Higher value gives lower watt readout
  current_res: "0.001"
  # Lower value gives lower voltage readout
  voltage_div: "2050"
  #was 1925

esphome:
  name: shelly-plus-1pm-01
  platformio_options:
    board_build.f_cpu: 160000000L

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: latest
    sdkconfig_options:
      CONFIG_FREERTOS_UNICORE: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_160: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "160"
      CONFIG_ESP_TASK_WDT_TIMEOUT_S: "20"
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: n
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y

wifi:
  ssid: "IOTDOM"
  password: !secret wifi_key
  domain: !secret domain
  #use_address: 192.168.6.77
  # Enable fallback hotspot (captive portal) in case wifi connection fails

  ap:
    ssid: "${device_name} Fallb Hotspot"
    password: !secret Fallback_Hotspot

logger:

api:

ota:

esp32_ble_tracker:
  scan_parameters:
    active: false

bluetooth_proxy:

button:
  - platform: safe_mode
    name: "(Safe Mode)"

time:
  - platform: homeassistant
    id: homeassistant_time

output:
  - platform: gpio
    id: "relay_output"
    pin: GPIO26

switch:
  - platform: output
    id: "relay"
    name: "${device_name} Relay"
    output: "relay_output"

binary_sensor:
  - platform: gpio
    name: "${device_name} Switch"
    pin: GPIO4
    on_press:
      then:
        - switch.toggle: "relay"
    filters:
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button"
    pin:
      number: GPIO25
      inverted: yes
      mode:
        input: true
        pullup: true
    on_press:
      then:
        - switch.toggle: "relay"
    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:
          - switch.turn_off: "relay"
  - 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: adc
    name: "${device_name} Relay Supply Voltage"
    pin: GPIO33
    attenuation: 11db
    filters:
      - multiply: 8
  - platform: hlw8012
    model: BL0937
    sel_pin:
      number: GPIO23
      inverted: true
    cf_pin: GPIO5
    cf1_pin: GPIO18
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${device_name} Current"
      unit_of_measurement: A
      accuracy_decimals: 3
      icon: mdi:flash-outline
    voltage:
      name: "${device_name} Voltage"
      unit_of_measurement: V
      accuracy_decimals: 1
      icon: mdi:flash-outline
    power:
      name: "${device_name} Power"
      unit_of_measurement: W
      id: power
      icon: mdi:flash-outline
      on_value_range:
        - above: "3600"
          then:
            - switch.turn_off: "relay"
    change_mode_every: 2
    update_interval: 10s
  - platform: total_daily_energy
    name: "${device_name} Daily energy consumed"
    power_id: power
    filters:
        - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:clock-alert

status_led:
  pin:
    number: GPIO0
    inverted: true

Hi there, is there any one having luck with flashing a Shelly plus i4 with esphome?

I have done:

and this pin layout:

similar to this:

Where I have connected pin3 to 4 and 2 to 1.

This gives me output on the serial (so it must be connected ok and in flash mode) but I am not able to successfully flash.

the error:

Using 'COM6' as serial port.
Connecting........_
Detecting chip type... ESP32
Connecting...

Chip Info:
 - Chip Family: ESP32
 - Chip Model: unknown ESP32 (revision 3)
 - Number of Cores: 1
 - Max CPU Frequency: 80MHz
 - Has Bluetooth: YES
 - Has Embedded Flash: YES
 - Has Factory-Calibrated ADC: YES
 - MAC Address: 08:3A:F2:00:AA:68
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
 - Flash Size: 4MB
 - Flash Mode: dio
 - Flash Frequency: 40MHz
Erasing flash (this may take a while)...
Unexpected error: Error while erasing flash: Timed out waiting for packet content

I have to get back… it works for a little while.

After placing it in the wall, booting it up the wifi wprks for a limited amount of time.
Locally it keeps working a while…
Then after a while also no local control possible anymore.

Practically impossible to track the serial logging…

Bummer.

Has anyone been successful in getting active Bluetooth connections?
Is it even possible?