Integrate Kogan SmarterHome products into HA

Yeah I have the same. Unfortunately not working…

binary_sensor:
  - platform: gpio
    id: toggle
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    internal: true
    on_press:
      then:
        - switch.toggle: relay

- - -

  - platform: gpio
    name: "$device"
    pin: GPIO14
    id: relay
    icon: "$icon"
    restore_mode: "$restore_mode"

Hi all, I got these light bulbs that I flashed using ESPHome and tuya-covert, here is the .yaml:

output:
  - platform: esp8266_pwm
    id: red
    pin: GPIO4
  - platform: esp8266_pwm
    id: green
    pin: GPIO12
  - platform: esp8266_pwm
    id: blue
    pin: GPIO14
  - platform: esp8266_pwm
    id: cold_white
    pin: GPIO5
  - platform: esp8266_pwm
    id: warm_white
    pin: GPIO13

Brightness and Color picker work outside of the box in HA but not the Color Temperature feature:

1 Like

Welcome to the forum :slight_smile:

did you set the light as rgbw in the ESPhome yaml file?

eg:

light:
  - platform: rgbw
    name: Ensuite Downlight
    red: output_red
    green: output_green
    blue: output_blue
    white: output_white
1 Like

Thanks for the quick reply and sorry for my ignorance, just discovered the difference between rgbw and rgbww!

I flashed it as a “custom rgbww” I think, like this:

Inspired by the /cw-ww-and-colour-temperature-slider-support-in-custom-light-output/148098/10 thread :slight_smile: I can only put 2 links in a post

try the code I provided, modified to suit your name and ID’s

I got one of these

tasmota it

wrote this

Thanks Dave, I used the following instructions in my YAML file but I can’t get the sliders in HA to be correctly mapped, the pin assignment for the output_white is probably not right or something is missing. The “white value” slider seems inactive. What do you recommend reading to understand how to figure out the pins mapping?

light:
  - platform: rgbw
    name: ${name}
    red: output_red
    green: output_green
    blue: output_blue
    white: output_white
  
output:
  - platform: esp8266_pwm
    id: output_red
    pin: GPIO4
  - platform: esp8266_pwm
    id: output_green
    pin: GPIO12
  - platform: esp8266_pwm
    id: output_blue
    pin: GPIO14
  - platform: esp8266_pwm
    id: output_white
    pin: GPIO13

Can I get a version of this with proper formatting? I can’t seem to get it to validate, as I’m having issues with the indentation.

Hey Lance

Try this -


substitutions:
  plug_name: plug01
  # Higher value gives lower watt readout
  #current_res: "0.00221"
  current_res: "0.00087"
  # Lower value gives lower voltage readout
  #voltage_div: "955"
  voltage_div: "2072"
esphome:
  name: ${plug_name}
  platform: ESP8266
  board: esp8285
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pwd
# Enable logging
logger:
# Enable Web server
web_server:
  port: 80
# Enable Home Assistant API
api:
  password: !secret esphome_api
ota:
  password: !secret esphome_ota
time:
  - platform: homeassistant
    id: homeassistant_time
    

switch:
- platform: gpio
  name: "${plug_name}_Relay"
  pin: GPIO14
  id: relay
#  restore_mode: ALWAYS_ON
- platform: gpio
  name: "${plug_name}_LED_Green"
  pin: GPIO13
  inverted: True
  restore_mode: ALWAYS_OFF
#- platform: gpio
#  name: "${plug_name}_LED_Red"
#  pin: GPIO13
#  inverted: True
#  restore_mode: ALWAYS_OFF
sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${plug_name}_Amperage"
      unit_of_measurement: A
    voltage:
      name: "${plug_name}_Voltage"
      unit_of_measurement: V
    power:
      name: "${plug_name}_Wattage"
      unit_of_measurement: W
      id: "${plug_name}_Wattage"
    change_mode_every: 8
    update_interval: 60s
  - platform: total_daily_energy
    name: "${plug_name}_Total Daily Energy"
    power_id: "${plug_name}_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
      
# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: ${plug_name}_Uptime Sensor
    
  - platform: wifi_signal
    name: "${plug_name}_WiFi Signal Sensor"
    update_interval: 300s
    
    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "${plug_name}_Button"
    on_press:
      - switch.toggle: relay
1 Like

“Kogan SmarterHome™ Smart Plug with Energy Meter & 5V 2.4A USB Ports”

If you’d like the button to work, use the following.

  - platform: gpio
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: true
    name: "$devicename Power Button"
    on_press:
     - switch.toggle: relay

  - platform: gpio
    pin:
      number: GPIO3
      mode: INPUT_PULLUP
      inverted: true
    name: "$devicename Power Button"
    on_press:
     - switch.toggle: relay

Yeah I know. Either item on its own doesn’t make the button work but having them both does…

2 Likes

Worked perfectly…Thanks all!!

@thi_baut

I got my Kogan Lights working in esphome with the following config (after adapting your config and @kanga_who’s tasmota config from a few posts back):

I couldn’t get the colour temp slider to transition between the white LEDs and the RGB LEDs though. (Solved! see below)

light:
  # merges the brightness slider and white level slider into one
  - platform: custom
    lambda: |-
      auto light_out = new BetterRGBWLightOutput(id(red), id(green), id(blue), id(cold_white), id(warm_white));
      App.register_component(light_out);
      return {light_out};
    lights:
      - name: $display_name
        default_transition_length: 500ms

sm16716:
  data_pin: GPIO14
  clock_pin: GPIO4
  num_channels: 3
  num_chips: 1
  
power_supply:
  - id: rgb_power
    pin: GPIO13
  
output:
  - platform: sm16716
    id: blue
    channel: 0
    power_supply: rgb_power
  - platform: sm16716
    id: green
    channel: 1
    power_supply: rgb_power
  - platform: sm16716
    id: red
    channel: 2
    power_supply: rgb_power
  - platform: esp8266_pwm
    id: warm_white
    pin: GPIO5
  - platform: esp8266_pwm
    id: cold_white
    pin: GPIO13

I also got the colour temperature to gradually switch between the RGB and main white LED light with the following modified BetterRGBWOutput code by user displaced:

/*  A Better RGBW(W) Output

    Based on/inspired by user *envy* at https://github.com/esphome/feature-requests/issues/212#issuecomment-498036079
    And modified by *kabloomy* for Australian Kogan SmarterHome lights

    Why?:

        I have RGBWW (RGB + Cool-White + Warm-White) LED bulbs.  After finding the correct PWM GPIOs to control each channel
        and setting them up with esphome and HomeAssistant, I noticed the controls in HA were weird.

        HA presented a brightness slider, colour temperature slider, 'white value' slider and an RGB picker.

        The 'white value' and 'brightness' only worked to brighten/dim the CW/WW and RGB LEDs respectively.  I wanted a single
        'brightness' slider that worked no matter if the bulb was showing white or colour.

    How?:

        This output checks what the desired state is.  If the RGB levels are equal, then the code turns off the RGB
        LEDs and turns on the Cool and Warm LEDs.  These levels set the white temperature, but not the brightness.

        So, we also grab the brightness setting and multiply the CW/WW levels by it to get final levels for CW/WW.

        If the desired RGB levels differ from eachother, then we know we want a coloured light.  So, the code 
        turns off the CW/WW LEDs and sets the RGB levels as desired.  We don't do a brightness multiplication here,
        since that already seems to have been applied.
*/

#pragma once

#include "esphome.h"

class BetterRGBWLightOutput : public Component, public LightOutput {
    public:
    BetterRGBWLightOutput(FloatOutput *red, FloatOutput *green, FloatOutput *blue, FloatOutput *cold_white, FloatOutput *warm_white)
    {
        red_ = red;
        green_ = green;
        blue_ = blue;
        cold_white_ = cold_white;
        warm_white_ = warm_white;
    }

    LightTraits get_traits() override {
        auto traits = LightTraits();
        traits.set_supports_brightness(true);
        traits.set_supports_rgb(true);
        traits.set_supports_color_temperature(true);
        traits.set_min_mireds(166);
        traits.set_max_mireds(370);
        return traits;
    }

    void write_state(LightState *state) override {
        float red, green, blue, cold_white, warm_white, brightness;
        state->current_values_as_rgbww(&red, &green, &blue, &cold_white, &warm_white);

        state->current_values_as_brightness(&brightness);

        if (red == green && red == blue && cold_white != 0)
        {
            // Cool white mode (RGB)
            // the cold_white pin doesn't seem to exist in the Kogan lights...
            // cold white is simulated with the RGB
            this->red_->set_level(cold_white * brightness);
            this->green_->set_level(cold_white * brightness);
            this->blue_->set_level(cold_white * brightness);
            this->cold_white_->set_level(0);
            this->warm_white_->set_level(0.5 * warm_white * brightness);
        }
        else if (red == green && red == blue)
        {
            // Warm white mode
            this->red_->set_level(0);
            this->green_->set_level(0);
            this->blue_->set_level(0);
            this->cold_white_->set_level(0);
            this->warm_white_->set_level(warm_white * brightness);
        }
        else
        {
            // RGB mode
            this->red_->set_level(red);
            this->green_->set_level(green);
            this->blue_->set_level(blue);
            this->cold_white_->set_level(0);
            this->warm_white_->set_level(0);
        }
    }

    protected:
    FloatOutput *red_;
    FloatOutput *green_;
    FloatOutput *blue_;
    FloatOutput *cold_white_;
    FloatOutput *warm_white_;
};
1 Like

cheers Asher, the last missing piece!

For other newbies like me, this needs to be in the “binary_sensor:” section

An FYI who runs into issues with Kogan WA template - the new Kogan White Temperature bulbs require a different tasmota template:

{"NAME":"GenioBulbCCT","GPIO":[0,0,0,0,0,37,0,0,0,38,0,0,0],"FLAG":0,"BASE":48}

The important bit there is the BASE: 48, using module 48 which has one channel for brightness and one for color temperature.

The product code is the same for old and new bulbs, I ran into it replacing older bulbs and couldn’t work out why the old template wasn’t working , gah!

2 Likes

Are you using this model: https://www.kogan.com/au/buy/kogan-smarterhome-smart-plug-energy-meter-5v-24a-usb-ports/
I can’t see a button, looking to buy one but I don’t know if it’s supported (different than https://www.kogan.com/au/buy/kogan-smarterhome-smart-plug-energy-meter/)

Button is on the bottom :+1:

Can flash using Tuya-convert using tasmota or esphome firmware

1 Like

Today I flashed a hihome smart switch (wpp 16s1) with tuyaconvert and esphome. Everything works but it shows the wrong voltages aprox 600 V… How do I calibrate this. I know I can do this with current_resistor and voltage_divider right? But what does these values say and how do I have to interpret them to calibrate the sensor.

I have the same issue, I got a Kogan Smart Plug that I flashed with tuya convert and the V seems off.

substitutions:
  plug_name: kogan_plug_01
  current_res: "0.00087"
  voltage_div: "2072"
   
switch:
- platform: gpio
  name: "${plug_name}_Relay"
  pin: GPIO14
  id: relay

- platform: gpio
  name: "${plug_name}_LED_Green"
  pin: GPIO13
  inverted: True
  restore_mode: ALWAYS_OFF

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${plug_name}_Amperage"
      unit_of_measurement: A
    voltage:
      name: "${plug_name}_Voltage"
      unit_of_measurement: V
    power:
      name: "${plug_name}_Wattage"
      unit_of_measurement: W
      id: "${plug_name}_Wattage"
    change_mode_every: 8
    update_interval: 60s

  - platform: total_daily_energy
    name: "${plug_name}_Total Daily Energy"
    power_id: "${plug_name}_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
      
# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: ${plug_name}_Uptime Sensor
    
  - platform: wifi_signal
    name: "${plug_name}_WiFi Signal Sensor"
    update_interval: 300s
    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: true
    name: "$plug_name Power Button"
    on_press:
     - switch.toggle: relay

  - platform: gpio
    pin:
      number: GPIO3
      mode: INPUT_PULLUP
      inverted: true
    name: "$plug_name Power Button"
    on_press:
     - switch.toggle: relay

My readings (I have an almost idle 2007 iMac running on Ubuntu plugged in, screen off, no GPU usage), the W seems to high for this computer (should be max 200W):

I use these values for the Gen2 Kogan Plugs

The ones you posted I think are from the Gen1 Plugs (without USB)

  current_res: "0.00225"
  voltage_div: "805"
1 Like