Xiaomi switch and binary sencor, controlling Sonoff switch

Hi all.

I it possible to use the Xiaomi switch to controll a sonoff switch?

The xiaomi entity is binary_sensor.switch_158d0001548880
sonoff entity is group.stuen and uses mqtt like this:

switch:

  • platform: mqtt
    name: “Stue Lampe K”
    state_topic: “stat/stuek/POWER”
    command_topic: “cmnd/stuek/power”
    payload_on: “ON”
    payload_off: “OFF”
    optimistic: false
    qos: 0
    retain: true

I also want to use the xioami pir sensor to controll lights in my appartment
the xiaomi entity is binary_sensor.motion_sensor_158d000153705a

Regards from Kenneth

Check the examples in the documentation https://home-assistant.io/components/xiaomi_aqara/#examples

I did, but it looks like the xiaomi switch only controlles the xiaomi Hub in the example : )

In te Action you can call wathever service you want.
What you see there are only examples!

Thanks. I Will Try to put something together.

More examples here: https://home-assistant.io/components/binary_sensor.xiaomi_aqara/#automation-examples

Thanks :slight_smile:

I got the second half of the automation to work.
I can turn off switch.kontorseng, but not on.
Any idea’s

This is my configuration:

automation:

  • id: 1
  • alias: Turn on all livingroomlights
    trigger:
    platform: event
    event_type: click
    event_data:
    entity_id: binary_sensor.switch_158d0001548880
    click_type: long_click_press
    action:
    service: homeassistant.turn_on
    entity_id: switch.kontorseng

automation:

  • id: 2
  • alias: Turn off all livingroomlights
    trigger:
    platform: event
    event_type: click
    event_data:
    entity_id: binary_sensor.switch_158d0001548880
    click_type: double_click_press
    action:
    service: homeassistant.turn_off
    entity_id: switch.kontorseng

double_click_press -> double

I got it to work with this configuration:

  • alias: Turn on all livingroomlights
    trigger:
    platform: event
    event_type: click
    event_data:
    entity_id: binary_sensor.switch_158d0001548880
    click_type: single
    action:
    service: switch.toggle
    entity_id: switch.kontorseng

Thanks a bunch for the help I got :slight_smile:

Here’s what I did to get the same working. With whitespace :wink:

  • id: ‘1528072044906’
    alias: New Automation
    trigger:
    • platform: event
      event_type: click
      event_data:
      entity_id: binary_sensor.switch_158d000155d38a
      click_type: single
      condition: []
      action:
      • service: switch.toggle
        entity_id: switch.sonoff_switch_01