Shelly 1PM?

I’ve made your of your config to flash 9 Shelly 1 Pms and it works great, apart from none of them report current or voltage. It’s always 0.0.

Power works fine though.

Is your’s reporting V and A OK?

What may I be missing?

Seems like current and voltage is not possible without hardware modification due to missing wiring.
See https://github.com/arendst/Tasmota/issues/5716

Thank you for finding that. I’ll waste no more time in trying to get the readings!

Are these able to be flashed with tuya-convert in the normal way? Are they affected by the encryption issues affecting other Tuya devices? I am trying to do one now but it isnt finding the device.

Shelly devices do not run Tuya, so no, you won’t be able to use tuya-convert.

However - in case you missed it - Shelly devices are now natively supported since v0.115, so there is no need to install a different firmware. If you still want to run Tasmota/ESPHome instead then you would need to flash with a serial connection, and the Shelly 1PM conveniently exposes the required pins on the outside of its case.

Does anyone know if the Shelly 1PM in HA displays/reads the current/voltage items natively as well? I can’t seem to find anyone to confirm/deny that.

Here is a sample Shelly 1PM entities list:


As you can see, current or voltage are not available.

I flashed shelly1pm with sonoff tasmota.i think it works fine.

I have connected CF1 to GPIO14 and SEL to GPIO12.
What would be the correct configuration? I think mA may have started working but not voltage…

@alferboy I have since replaced my 1pm’s with 2.5’s, which have a different sensor. So I am not setup to test this, but referring to the esphome docs it appears my originally posted config above may be incorrect… Try using the config posted on the info page instead:

sensor:
  - platform: hlw8012
    sel_pin: 5
    cf_pin: 14
    cf1_pin: 13
    current:
      name: "HLW8012 Current"
    voltage:
      name: "HLW8012 Voltage"
    power:
      name: "HLW8012 Power"
    energy:
      name: "HLW8012 Energy"
    update_interval: 60s

Also note at the bottom of the page there is a section about a “Permanent SEL Pin” hardware variant, which only has measurement mode available (likely power only). I suppose if you have a 1pm that has the pullup, you could find out how to remove it from the board to allow all 3 measurement modes.

@truglodite,

That was my base to add current and voltage, but according to the pins used as in https://github.com/arendst/Tasmota/issues/5716 (GPIO12 and GPIO14). There is no pull-up a.
I’ve connected those wires but it seems maybe something’s mixed up on the voltage/current (they seem maybe “swapped”).

With a 4w led bulb I was getting:

[19:32:32][D][hlw8012:063]: Got power=29.0W, current=21.7A
[19:32:42][D][hlw8012:063]: Got power=29.0W, current=21.7A
[19:33:02][D][hlw8012:071]: Got power=27.9W, voltage=1.5V
[19:33:12][D][hlw8012:071]: Got power=29.0W, voltage=1.6V
[19:33:32][D][hlw8012:063]: Got power=29.0W, current=21.7A
[19:33:42][D][hlw8012:063]: Got power=29.0W, current=21.7A
[19:34:02][D][hlw8012:071]: Got power=29.0W, voltage=1.6V
[19:34:12][D][hlw8012:071]: Got power=29.0W, voltage=1.5V
[19:34:32][D][hlw8012:063]: Got power=27.9W, current=21.8A

I changed the voltage divider so that voltage would go to around 230V and got (same wiring - check the power increase):

[19:35:22][D][hlw8012:071]: Got power=4282.2W, voltage=238.1V
[19:35:32][D][hlw8012:071]: Got power=4440.8W, voltage=231.8V
[19:35:52][D][hlw8012:063]: Got power=4282.2W, current=21.9A
[19:36:02][D][hlw8012:063]: Got power=4440.8W, current=21.9A
[19:36:22][D][hlw8012:071]: Got power=4440.8W, voltage=231.8V
[19:36:32][D][hlw8012:071]: Got power=4440.8W, voltage=231.8V
[19:36:52][D][hlw8012:063]: Got power=4440.8W, current=21.9A
[19:37:02][D][hlw8012:063]: Got power=4440.8W, current=21.9A
[19:37:22][D][hlw8012:071]: Got power=4282.2W, voltage=231.8V
[19:37:32][D][hlw8012:071]: Got power=4440.8W, voltage=238.1V
[19:37:52][D][hlw8012:063]: Got power=4282.2W, current=21.9A
[19:38:02][D][hlw8012:063]: Got power=4440.8W, current=21.9A
[19:38:22][D][hlw8012:071]: Got power=0.0W, voltage=75.2V
[19:38:32][D][hlw8012:071]: Got power=475.8W, voltage=87.7V
[19:38:52][D][hlw8012:063]: Got power=317.2W, current=21.7A
[19:39:02][D][hlw8012:063]: Got power=317.2W, current=21.7A
[19:39:22][D][hlw8012:071]: Got power=0.0W, voltage=81.5V
[19:39:32][D][hlw8012:071]: Got power=317.2W, voltage=68.9V
[19:39:52][D][hlw8012:063]: Got power=0.0W, current=21.7A
[19:40:02][D][hlw8012:063]: Got power=317.2W, current=21.6A
[19:40:22][D][hlw8012:071]: Got power=317.2W, voltage=87.7V
[19:40:32][D][hlw8012:071]: Got power=0.0W, voltage=75.2V
[19:40:52][D][hlw8012:063]: Got power=317.2W, current=21.7A

When voltage is belows 100v is when I turn off the relay. Yet current is always fixed, leading me to believe that they are somehow exchanged. Perhaps the sel pin needs invertion? very odd…

Reading that, my understanding is that the 1pm has some disconnected pins. It looks like Vorta came up with a hack that requires soldering 2 wires on the esp chip. That could be translated to esphome configs easily, but would still require the soldering.

Now, the “proof”:
Consider the “sent watts” as correct (they are pretty close).
Look at when I change the 4w bulb for a 2000w heater…
Takes a few seconds for the value to raise but when it does the “current” stays the same, and the “voltage” increases.
I think the “sel” pin needs inversion. I see no option for that…

[19:57:09][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.65142 mA with 2 decimals of accuracy
[19:57:09][D][sensor:092]: 'Test Shelly1PM Power': Sending state 5.06800 W with 0 decimals of accuracy
[19:57:09][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.54017 E with 1 decimals of accuracy
[19:57:11][D][sensor:092]: 'Test Shelly1PM WiFi Signal': Sending state -67.00000 dB with 0 decimals of accuracy
[19:57:14][D][hlw8012:063]: Got power=29.0W, current=21.6A
[19:57:14][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.60797 mA with 2 decimals of accuracy
[19:57:14][D][sensor:092]: 'Test Shelly1PM Power': Sending state 4.69646 W with 0 decimals of accuracy
[19:57:14][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.58039 E with 1 decimals of accuracy
[19:57:19][D][sensor:092]: 'Test Shelly1PM Power': Sending state 4.69646 W with 0 decimals of accuracy
[19:57:19][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.62062 E with 1 decimals of accuracy
[19:57:24][D][hlw8012:071]: Got power=29.0W, voltage=1.6V
[19:57:24][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 1.55282 V with 1 decimals of accuracy
[19:57:24][D][sensor:092]: 'Test Shelly1PM Power': Sending state 4.69646 W with 0 decimals of accuracy
[19:57:24][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.66084 E with 1 decimals of accuracy
[19:57:29][D][hlw8012:071]: Got power=29.0W, voltage=1.6V
[19:57:29][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 1.55282 V with 1 decimals of accuracy
[19:57:29][D][sensor:092]: 'Test Shelly1PM Power': Sending state 4.69646 W with 0 decimals of accuracy
[19:57:29][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.70107 E with 1 decimals of accuracy
[19:57:34][D][sensor:092]: 'Test Shelly1PM Power': Sending state 4.69646 W with 0 decimals of accuracy
[19:57:34][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.74129 E with 1 decimals of accuracy
[19:57:39][D][hlw8012:063]: Got power=24.8W, current=21.6A
[19:57:39][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.61666 mA with 2 decimals of accuracy
[19:57:39][D][sensor:092]: 'Test Shelly1PM Power': Sending state 3.95338 W with 0 decimals of accuracy
[19:57:39][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.77577 E with 1 decimals of accuracy
[19:57:41][D][adc:056]: 'shelly1pm_test_source_sensor': Got voltage=0.46V
[19:57:41][D][sensor:092]: 'shelly1pm_test_source_sensor': Sending state 0.45508 V with 2 decimals of accuracy
[19:57:41][D][resistance:037]: 'shelly1pm_test_resistance_sensor' - Resistance 5118.8Ω
[19:57:41][D][sensor:092]: 'shelly1pm_test_resistance_sensor': Sending state 5118.76953 Ω with 1 decimals of accuracy
[19:57:41][D][ntc:026]: 'Test Shelly1PM Temperature' - Temperature: 43.9°C
[19:57:41][D][sensor:092]: 'Test Shelly1PM Temperature': Sending state 43.89619 °C with 1 decimals of accuracy
[19:57:44][D][hlw8012:063]: Got power=0.0W, current=21.6A
[19:57:44][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.63694 mA with 2 decimals of accuracy
[19:57:44][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:57:44][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.77577 E with 1 decimals of accuracy
[19:57:49][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:57:49][D][sensor:092]: 'shelly1pm_test Energy': Sending state 0.77864 E with 1 decimals of accuracy
[19:57:55][D][hlw8012:071]: Got power=2465.9W, voltage=66.0V
[19:57:55][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 66.03566 V with 1 decimals of accuracy
[19:57:55][D][sensor:092]: 'Test Shelly1PM Power': Sending state 442.37036 W with 0 decimals of accuracy
[19:57:55][D][sensor:092]: 'shelly1pm_test Energy': Sending state 4.20353 E with 1 decimals of accuracy
[19:58:00][D][hlw8012:071]: Got power=9973.3W, voltage=256.8V
[19:58:00][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 256.78717 V with 1 decimals of accuracy
[19:58:00][D][sensor:092]: 'Test Shelly1PM Power': Sending state 1790.68835 W with 0 decimals of accuracy
[19:58:00][D][sensor:092]: 'shelly1pm_test Energy': Sending state 18.05535 E with 1 decimals of accuracy
[19:58:05][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2245.45312 W with 0 decimals of accuracy
[19:58:05][D][sensor:092]: 'shelly1pm_test Energy': Sending state 35.42400 E with 1 decimals of accuracy
[19:58:10][D][hlw8012:063]: Got power=12383.4W, current=20.8A
[19:58:10][D][sensor:092]: 'Test Shelly1PM Current': Sending state 20.77366 mA with 2 decimals of accuracy
[19:58:10][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2223.53223 W with 0 decimals of accuracy
[19:58:10][D][sensor:092]: 'shelly1pm_test Energy': Sending state 52.62313 E with 1 decimals of accuracy
[19:58:10][I][ota:046]: Boot seems successful, resetting boot loop counter.
[19:58:11][D][sensor:092]: 'Test Shelly1PM WiFi Signal': Sending state -69.00000 dB with 0 decimals of accuracy
[19:58:15][D][hlw8012:063]: Got power=12356.5W, current=20.8A
[19:58:15][D][sensor:092]: 'Test Shelly1PM Current': Sending state 20.79973 mA with 2 decimals of accuracy
[19:58:15][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2218.70215 W with 0 decimals of accuracy
[19:58:15][D][sensor:092]: 'shelly1pm_test Energy': Sending state 69.78490 E with 1 decimals of accuracy
[19:58:20][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2217.58765 W with 0 decimals of accuracy
[19:58:20][D][sensor:092]: 'shelly1pm_test Energy': Sending state 86.93806 E with 1 decimals of accuracy
[19:58:25][D][hlw8012:071]: Got power=12325.4W, voltage=314.2V
[19:58:25][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 314.15973 V with 1 decimals of accuracy
[19:58:25][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2213.12915 W with 0 decimals of accuracy
[19:58:25][D][sensor:092]: 'shelly1pm_test Energy': Sending state 104.05675 E with 1 decimals of accuracy
[19:58:29][D][hlw8012:071]: Got power=12329.6W, voltage=313.9V
[19:58:29][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 313.91455 V with 1 decimals of accuracy
[19:58:29][D][sensor:092]: 'Test Shelly1PM Power': Sending state 2213.87231 W with 0 decimals of accuracy
[19:58:29][D][sensor:092]: 'shelly1pm_test Energy': Sending state 121.18116 E with 1 decimals of accuracy
[19:58:34][D][sensor:092]: 'Test Shelly1PM Power': Sending state 1804.80688 W with 0 decimals of accuracy
[19:58:34][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:58:39][D][hlw8012:063]: Got power=0.0W, current=21.9A
[19:58:39][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.85420 mA with 2 decimals of accuracy
[19:58:39][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:58:39][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:58:41][D][adc:056]: 'shelly1pm_test_source_sensor': Got voltage=0.37V
[19:58:41][D][sensor:092]: 'shelly1pm_test_source_sensor': Sending state 0.37207 V with 2 decimals of accuracy
[19:58:41][D][resistance:037]: 'shelly1pm_test_resistance_sensor' - Resistance 4066.4Ω
[19:58:41][D][sensor:092]: 'shelly1pm_test_resistance_sensor': Sending state 4066.44019 Ω with 1 decimals of accuracy
[19:58:41][D][ntc:026]: 'Test Shelly1PM Temperature' - Temperature: 51.0°C
[19:58:41][D][sensor:092]: 'Test Shelly1PM Temperature': Sending state 50.95559 °C with 1 decimals of accuracy
[19:58:44][D][hlw8012:063]: Got power=0.0W, current=21.9A
[19:58:44][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.89186 mA with 2 decimals of accuracy
[19:58:44][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:58:44][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:58:49][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:58:49][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:58:54][D][hlw8012:071]: Got power=0.0W, voltage=0.0V
[19:58:55][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 0.00000 V with 1 decimals of accuracy
[19:58:55][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:58:55][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:58:59][D][hlw8012:071]: Got power=0.0W, voltage=0.0V
[19:58:59][D][sensor:092]: 'shelly1pm_test Voltage': Sending state 0.00000 V with 1 decimals of accuracy
[19:58:59][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:58:59][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:59:04][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:59:05][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:59:10][D][hlw8012:063]: Got power=0.0W, current=22.0A
[19:59:10][D][sensor:092]: 'Test Shelly1PM Current': Sending state 21.96139 mA with 2 decimals of accuracy
[19:59:10][D][sensor:092]: 'Test Shelly1PM Power': Sending state 0.00000 W with 0 decimals of accuracy
[19:59:10][D][sensor:092]: 'shelly1pm_test Energy': Sending state 135.14217 E with 1 decimals of accuracy
[19:59:11][D][sensor:092]: 'Test Shelly1PM WiFi Signal': Sending state -61.00000 dB with 0 decimals of accuracy

@truglodite:

I did that soldering, that’s the issue. I soldered the wires as suggested.

    cf1_pin: GPIO14
    sel_pin: GPIO12

And it does get current/voltage values.
Yet, they show up as you see, seemingly swapped.

Does anyone know if this fire hazard issue related to the ade7953 in the shelly 2.5 Shelly 2.5 + ESPHome: potential fire hazard + fix | Savjee.be is all present in the Shelly 1PM and if so if the same fix applies?

To my understanding they have different chips in them. Also my ESPHome flashed shelly 1PM and same with original Shelly FW seem to be running at the same temperature (~50 degrees).

Are you having heat issues with 1PM?

Awesome, like that and while I was able to find a working config here, I always start looking at https://www.esphome-devices.com/ first.
Now I have two questions, is esphome-devices not good to start over or why do these configs not end up on that website?
Is there anything better to get things rolling with esphome and a “working” config?

I am thinking about Tasmota Device Templates Repository - Templates for Tasmota which is THE go to site for getting devices up and running with Tasmota. Lots of people buy devices because the show up there with a configuration.

Thanks for the 1PM config anyhow.

Because no one takes the time to do so… I did a few and it takes some time to do so.

Here’s my config I compiled from a few sources I found here and there. What’s added:

  • restart switch
  • wifi signal sensor
  • polynomial calibration which works for me much better than linear calibration
  • total daily energy sensor
  • overheat protection with notification
# Shelly 1PM, compiled from:
#   - https://community.home-assistant.io/t/shelly-1pm/118929/
#   - https://gitmemory.com/issue/jonathanadams/esphome-configs/96/652744282
#   - https://www.esphome-devices.com/devices/Shelly-1
#   - https://www.esphome-devices.com/devices/Shelly-25/

substitutions:
  name: "shelly1pm-vypinac-sklep-technicka"
  name_id: "vypinac_sklep_technicka"
  friendly_name: "Vypinac sklep technicka"
  
  max_temp: "70.0"

esphome:
  name: ${name}
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret ssid
  password: !secret password
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${friendly_name} Hotspot"
    password: !secret password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret password

ota:
  password: !secret password

time:
  - platform: homeassistant
    id: homeassistant_time

switch:
  - platform: gpio
    name: "${friendly_name} Relay"
    icon: "mdi:electric-switch"
    pin: GPIO15
    id: relay
    restore_mode: restore_default_off
    
  - platform: restart
    name: "${friendly_name} Restart"
    
sensor:
  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s
    
  - platform: hlw8012
    cf_pin: GPIO05
    cf1_pin: GPIO13 # not used because it is not available on the 1PM but it is needed to compile
    sel_pin: GPIO14 # not used because it is not available on the 1PM but it is needed to compile
    power:
      name: "${friendly_name} Power"
      unit_of_measurement: W
      id: "${name_id}_power"
      icon: mdi:flash-circle
      accuracy_decimals: 1
      filters:
      # Reading from the ESPHome log (from the device) -> actual measured value (different combinations of bulbs on 3 bulb chandelier)
      # Polynomial calibration works best in my case. I created an excel graph with polynomial trend line in Excel based on the datapoints bellow and degree of 5 or 6 works best.
      - calibrate_polynomial:
          degree: 5
          datapoints:
            - 27.9 -> 5.0
            - 43.4 -> 7.0
            - 55.9 -> 10.0
            - 65.2 -> 11.0
            - 82.7 -> 15.0
            - 128.3 -> 21.0
            - 212 -> 35.0
            - 382.7 -> 60.0
            - 451 -> 75.0
            - 768.5 -> 120.0
            - 937.1 -> 150.0
            - 1217.4 -> 195.0
            - 1410.9 -> 225.0
      # Make everything below 2W appear as just 0W.
      # Furthermore it corrects 1.0W for the power usage of the plug.
      - lambda: if (x < (2 + 1)) return 0; else return (x - 1);
    update_interval: 10s
    
  - platform: total_daily_energy
    name: "${friendly_name} Total Daily Energy"
    power_id: "${name_id}_power"
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kW
    
  # NTC Temperature
  - platform: ntc
    sensor: "${name_id}_resistance_sensor"
    name: "${friendly_name} Temperature"
    id: "${name_id}_temperature"
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    icon: mdi:thermometer
    calibration:
      b_constant: 3350
      reference_resistance: 10kOhm
      reference_temperature: 298.15K
  - platform: resistance
    id: "${name_id}_resistance_sensor"
    sensor: "${name_id}_source_sensor"
    configuration: DOWNSTREAM
    resistor: 32kOhm
  - platform: adc
    id: "${name_id}_source_sensor"
    pin: A0
    update_interval: 30s

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
  
  # Binary sensor for the button press
  - platform: gpio
    name: "${friendly_name} Input"
    pin:
      number: GPIO4
    on_state:
      - switch.toggle: relay
    #on_press:
    #  - switch.turn_on: relay
    #on_release:
    #  - switch.turn_off: relay

status_led:
  pin: GPIO0
  #inverted: true

# output:
  # # Relay state led
  # - platform: esp8266_pwm
    # id: state_led
    # pin:
      # number: GPIO00
      # inverted: true

# Overheat Protection
interval:
  - interval: 100ms
    then:
      if:
        condition:
          and:
            - sensor.in_range:
                id: "${name_id}_temperature"
                above: ${max_temp}
            - switch.is_on: relay
        then:
          - switch.turn_off: relay
          - homeassistant.service:
              service: persistent_notification.create
              data:
                title: Message from ${friendly_name}
              data_template:
                message: Switch turned off because temperature exceeded ${max_temp} °C.

I’m sorry for not posting the config there, but it’s not really easy to do so and I can’t easily figure it out with time limitations on my hands.

9 Likes

Awesome, thanks for sharing your findings regarding calibration! I suspected linear was going to be a bit off… kinda surprised it lines up with 5th/6th order, but then I know nothing about the sensor.