Some help to migrate ESPeasy to ESPhome

Hi All,

Can someone help me with follow.

I want do some actions based on state of sensor:

sensor:
  # MOTION
  - platform: mqtt_subscribe
    name: "MQTT Listen - Motion"
    topic: homeassistant/motion/toilet

I want change neopixel color when this sensor state is 1 and change color again when state is 0

I get lots of things work now. Wondering if things can be shorter and smarter:

esphome:
  name: meek-test
  
esp8266:
  board: nodemcuv2

logger: # Enable logging

api: # Enable Home Assistant API
  encryption:
    key: "SNAP SKIP HIDDEN"

ota:
  password: "SNAP SKIP HIDDEN"

wifi:
  ssid: SNAP SKIP HIDDEN
  password: SNAP SKIP HIDDEN
  power_save_mode: none

  reboot_timeout: 30min
  
  fast_connect: true

mqtt:
  broker: 192.168.100.24
  username: SNAP SKIP HIDDEN
  password: SNAP SKIP HIDDEN
  client_id: esphome
  discovery: true

light:
  - platform: neopixelbus
    default_transition_length: 0s
    type: GRB
    variant: 800KBPS
    pin: GPIO2
    num_leds: 2
    name: "NeoPixel"
    id: light1

switch:
  - platform: gpio
    pin: D1
    name: "Switch 1"
    id: switch1

binary_sensor:
  - platform: gpio
    pin: D6
    name: "Touch 1"
    on_press:
      - switch.toggle: switch1
      - if:
          condition:
            switch.is_on: switch1
          then:
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%
      - if:
          condition:
            switch.is_off: switch1
          then:
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_daytime).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_evening).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_kodi).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 93%
                      green: 0%
                      blue: 93%
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_appletv).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 100%
                      green: 0%
                      blue: 0%
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_tv).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 0%
                      green: 25%
                      blue: 53%
            - if:
                condition:
                  lambda: |-
                    return id(mqtt_listen_nintendo).state > 0;
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 36%
                      green: 28%
                      blue: 55%

sensor:
  # SCENES
  - platform: mqtt_subscribe
    name: "MQTT Listen - Guests"
    id: mqtt_listen_guests
    accuracy_decimals: 0
    topic: homeassistant/scenes/guests

  - platform: mqtt_subscribe
    name: "MQTT Listen - Goodnight"
    id: mqtt_listen_goodnight
    accuracy_decimals: 0
    topic: homeassistant/scenes/goodnight
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 20%
                green: 31%
                blue: 9%

  - platform: mqtt_subscribe
    name: "MQTT Listen - Daytime"
    id: mqtt_listen_daytime
    accuracy_decimals: 0
    topic: homeassistant/scenes/daytime
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 100%
                green: 0%
                blue: 0%

  - platform: mqtt_subscribe
    name: "MQTT Listen - Evening"
    id: mqtt_listen_evening
    accuracy_decimals: 0
    topic: homeassistant/scenes/evening
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 100%
                green: 0%
                blue: 0%

  - platform: mqtt_subscribe
    name: "MQTT Listen - AppleTV"
    topic: homeassistant/scenes/appletv
    id: mqtt_listen_appletv
    accuracy_decimals: 0
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 55%
                green: 55%
                blue: 0%
  
  - platform: mqtt_subscribe
    name: "MQTT Listen - Kodi"
    id: mqtt_listen_kodi
    accuracy_decimals: 0
    topic: homeassistant/scenes/kodi
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 93%
                green: 0%
                blue: 93%

  - platform: mqtt_subscribe
    name: "MQTT Listen - Nintendo"
    id: mqtt_listen_nintendo
    accuracy_decimals: 0
    topic: homeassistant/scenes/nintendo
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 36%
                green: 28%
                blue: 55%

  - platform: mqtt_subscribe
    name: "MQTT Listen - tv"
    id: mqtt_listen_tv
    accuracy_decimals: 0
    topic: homeassistant/scenes/tv
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 0%
                green: 25%
                blue: 53%

  # MOTION
  - platform: mqtt_subscribe
    name: "MQTT Listen - Motion"
    id: mqtt_listen_motion
    accuracy_decimals: 0
    topic: homeassistant/motion/toilet
    on_value:
      then:
        if:
          condition:
            lambda: 'return x > 0;'
          then: 
            - light.turn_on: 
                id: light1
                brightness: 100%
                red: 0%
                green: 0%
                blue: 100%
          else:
            - if:
                condition:
                  switch.is_on: switch1
                then:
                  - light.turn_on: 
                      id: light1
                      brightness: 100%
                      red: 0%
                      green: 100%
                      blue: 0%
            - if:
                condition:
                  switch.is_off: switch1
                then:
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_daytime).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_evening).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_kodi).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 93%
                            green: 0%
                            blue: 93%
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_appletv).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 100%
                            green: 0%
                            blue: 0%
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_tv).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 0%
                            green: 25%
                            blue: 53%
                  - if:
                      condition:
                        lambda: |-
                          return id(mqtt_listen_nintendo).state > 0;
                      then:
                        - light.turn_on: 
                            id: light1
                            brightness: 100%
                            red: 36%
                            green: 28%
                            blue: 55%