SOLVED: Trying to define one of the outputs of a SHP7 (dual socket) as a light

I have this working as two switches, but I’m trying redefine one of the outputs as a light instead of a switch.

I’ve built this:

substitutions:
  device_name: serverroompower
  # Higher value gives lower watt readout
  current_res: '0.002291'
  # Lower value gives lower voltage readout
  voltage_div: '940'

esphome:
  name: '${device_name}'
  platform: ESP8266
  board: esp8285
  on_boot:
    then:
      - switch.turn_on: relay1
#      - switch.turn_on: relay2
      
wifi:
  ssid: !secret wifissid
  password: !secret wifipw
#  reboot_timeout: 60min
  manual_ip:
    static_ip: 10.11.13.43
    gateway: 10.11.13.1
    subnet: 255.255.255.0
#  use_address: 10.11.12.201
  fast_connect: true
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name} Hotspot"
    password: !secret appw

logger:
  baud_rate: 0

web_server:
  port: 80
  auth:
    username: !secret webuser
    password: !secret webpw

api:

ota:
  password: !secret otapw

time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:
  - platform: version
    name: "${device_name} ESPHome Version"
  - platform: wifi_info
    ip_address:
      name: "${device_name} ip"
    ssid:
      name: "${device_name} ssid"

binary_sensor:
  - platform: gpio
    id: button1
    name: button1
    internal: true
    pin:
      number: GPIO0
    on_press:
      - switch.toggle: relay1
  - platform: gpio
    id: button2
    name: button2
    internal: true
    pin:
      number: GPIO15
    on_press:
      - light.toggle: relay2

output:
  - platform: esp8266_pwm
    id: led1
    pin:
      number: GPIO13
      inverted: true
  - platform: esp8266_pwm
    id: led2
    pin:
      number: GPIO2
      inverted: true
  - platform: esp8266_pwm
    id: relay2
    pin: GPIO16

switch:
  - platform: gpio
    pin: GPIO14
    id: relay1
    name: 'server'
    on_turn_on:
      - output.turn_on: led1
    on_turn_off:
      - output.turn_off: led1

light:
  - platform: binary
    name: "Freezerlight"
    output: relay2

status_led:
  pin:
    number: GPIO01
    inverted: true

sensor:
  - platform: wifi_signal
    name: '${device_name} wifi signal'
    update_interval: 60s
    accuracy_decimals: 0
  - platform: uptime
    name: '${device_name} uptime'
    unit_of_measurement: days
    update_interval: 300s
    accuracy_decimals: 1
    filters:
      - multiply: 0.000011574
  - platform: hlw8012
    sel_pin:
      number: GPIO03
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    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'
      icon: mdi:flash-outline
    power:
      name: '${device_name} power'
      unit_of_measurement: 'kW'
      id: power
      accuracy_decimals: 3
      filters:
        - multiply: 0.001
      icon: mdi:flash-outline
    change_mode_every: 4
    update_interval: 10s
  - platform: total_daily_energy
    name: '${device_name} daily energy'
    power_id: power
    unit_of_measurement: kWh
    accuracy_decimals: 5

But I get an error:

ID ‘relay2’ of type esp8266_pwm: :ESP8266PWM doesn’t inherit from light::LightState. Please double check your ID is pinting to the correct value.

I don’t understand how to solve that?

The id relay2 refers to the pwm pin defined here, not the light entity you want.

  - platform: esp8266_pwm
    id: relay2
    pin: GPIO16

Change the id by appending _pin:

output:
  - platform: esp8266_pwm
    id: relay2_pin
    pin: GPIO16

light:
  - platform: binary
    name: "Freezerlight"
    output: relay2_pin
    id: relay2

I actualy got it fixed, but had to go to 1.16.0-dev
Here is 1 output set up as a switch and the other is set up as a light (it’s a dualoutput plug).

substitutions:
  device_name: serverroompower
  # Higher value gives lower watt readout
  current_res: '0.002291'
  # Lower value gives lower voltage readout
  voltage_div: '940'
  # BW-SHP7, dual outlet with powermonitoring.
  # One button for each relay, and one red led for each relay, as well as a blue status led
  # Static IP is configured, and fast_connect is enabled, as the SSID is hidden
  # Webserver is active and pw protected, and the OTA is password protected
  
esphome:
  name: '${device_name}'
  platform: ESP8266
  board: esp8285
  on_boot:
    then:
      - switch.turn_on: relay1
#      - switch.turn_on: relay2
      
wifi:
  ssid: !secret wifissid
  password: !secret wifipw
#  reboot_timeout: 60min
  manual_ip:
    static_ip: 10.11.13.43
    gateway: 10.11.13.1
    subnet: 255.255.255.0
#  use_address: 10.11.12.201
  fast_connect: true
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name} Hotspot"
    password: !secret appw

logger:
  baud_rate: 0

web_server:
  port: 80
  auth:
    username: !secret webuser
    password: !secret webpw

api:

ota:
  password: !secret otapw

time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:
  - platform: version
    name: "${device_name} ESPHome Version"
  - platform: wifi_info
    ip_address:
      name: "${device_name} ip"
    ssid:
      name: "${device_name} ssid"

binary_sensor:
  - platform: gpio
    id: button1
    name: button1
    internal: true
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      - switch.toggle: relay1
  - platform: gpio
    id: button2
    name: button2
    internal: true
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      - light.toggle: relay2

output:
  - platform: esp8266_pwm
    id: led1
    pin:
      number: GPIO13
      inverted: true
  - platform: esp8266_pwm
    id: led2
    pin:
      number: GPIO2
      inverted: true
  - platform: gpio
    id: light_relay
    pin: GPIO16

switch:
  - platform: gpio
    pin: GPIO14
    id: relay1
    name: 'server'
    on_turn_on:
      - output.turn_on: led1
    on_turn_off:
      - output.turn_off: led1

light:
  - platform: binary
    id: relay2
    name: freezerlight
    output: light_relay
    on_turn_on:
      - output.turn_on: led2
    on_turn_off:
      - output.turn_off: led2

status_led:
  pin:
    number: GPIO01
    inverted: true

sensor:
  - platform: wifi_signal
    name: '${device_name} wifi signal'
    update_interval: 60s
    accuracy_decimals: 0
  - platform: uptime
    name: '${device_name} uptime'
    unit_of_measurement: days
    update_interval: 300s
    accuracy_decimals: 1
    filters:
      - multiply: 0.000011574
  - platform: hlw8012
    sel_pin:
      number: GPIO03
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    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'
      icon: mdi:flash-outline
    power:
      name: '${device_name} power'
      unit_of_measurement: 'kW'
      id: power
      accuracy_decimals: 3
      filters:
        - multiply: 0.001
      icon: mdi:flash-outline
    change_mode_every: 4
    update_interval: 10s
  - platform: total_daily_energy
    name: '${device_name} daily energy'
    power_id: power
    unit_of_measurement: kWh
    accuracy_decimals: 5