esphome:   name: bedroom   friendly_name: bedroom esp32:   board: esp32dev   framework:     type: esp-idf external_components:   - source:       type: git       url: https://github.com/hzkincony/esphome-tuya-iot       ref: v1.2.1 time:   - platform: homeassistant     id: homeassistant_time # Example configuration entry for ESP32 i2c:   sda: 4   scl: 5   scan: true   id: bus_a # Example configuration entry ethernet:   type: LAN8720   mdc_pin: GPIO23   mdio_pin: GPIO18   clk_mode: GPIO17_OUT   phy_addr: 0   # Optional manual IP   manual_ip:     static_ip: 192.168.16.150     gateway: 192.168.16.1     subnet: 255.255.255.0   # Example configuration entry pcf8574:   - id: 'pcf8574_hub_out_1'  # for output channel 1-8     address: 0x24   - id: 'pcf8574_hub_out_2'  # for output channel 9-16     address: 0x25   - id: 'pcf8574_hub_in_1'  # for input channel 1-8     address: 0x21   - id: 'pcf8574_hub_in_2'  # for input channel 9-16     address: 0x22 # Individual outputs switch:   - platform: template     name: RF Power Button     turn_on_action:       - remote_transmitter.transmit_rc_switch_raw:           code: '0101011111111101000000111'           protocol: 1           repeat:             times: 2             wait_time: 20ms     turn_off_action:       - remote_transmitter.transmit_rc_switch_raw:           code: '0101011111111101000000111'           protocol: 1           repeat:             times: 2             wait_time: 20ms   - platform: gpio     name: "light1"     id: light1     on_turn_on:       - lambda: !lambda |-           id(tuya_iot_component).property_report("light1", true);     on_turn_off:       - lambda: !lambda |-           id(tuya_iot_component).property_report("light1", false);       pin:       pcf8574: pcf8574_hub_out_1       number: 0       mode: OUTPUT       inverted: true   - platform: gpio     name: "light2"     id: light2     on_turn_on:       - lambda: !lambda |-           id(tuya_iot_component).property_report("light2", true);     on_turn_off:       - lambda: !lambda |-           id(tuya_iot_component).property_report("light2", false);       pin:       pcf8574: pcf8574_hub_out_1       number: 1       mode: OUTPUT       inverted: true         - platform: gpio     name: "light3"     pin:       pcf8574: pcf8574_hub_out_1       number: 2       mode: OUTPUT       inverted: true         - platform: gpio     name: "light4"     pin:       pcf8574: pcf8574_hub_out_1       number: 3       mode: OUTPUT       inverted: true         - platform: gpio     name: "light5"     pin:       pcf8574: pcf8574_hub_out_1       number: 4       mode: OUTPUT       inverted: true         - platform: gpio     name: "light6"     pin:       pcf8574: pcf8574_hub_out_1       number: 5       mode: OUTPUT       inverted: true   - platform: gpio     name: "light7"     pin:       pcf8574: pcf8574_hub_out_1       number: 6       mode: OUTPUT       inverted: true         - platform: gpio     name: "light8"     pin:       pcf8574: pcf8574_hub_out_1       number: 7       mode: OUTPUT       inverted: true         - platform: gpio     name: "light9"     pin:       pcf8574: pcf8574_hub_out_2       number: 0       mode: OUTPUT       inverted: true   - platform: gpio     name: "light10"     pin:       pcf8574: pcf8574_hub_out_2       number: 1       mode: OUTPUT       inverted: true   - platform: gpio     name: "light11"     pin:       pcf8574: pcf8574_hub_out_2       number: 2       mode: OUTPUT       inverted: true         - platform: gpio     name: "light12"     pin:       pcf8574: pcf8574_hub_out_2       number: 3       mode: OUTPUT       inverted: true         - platform: gpio     name: "light13"     pin:       pcf8574: pcf8574_hub_out_2       number: 4       mode: OUTPUT       inverted: true         - platform: gpio     name: "light14"     pin:       pcf8574: pcf8574_hub_out_2       number: 5       mode: OUTPUT       inverted: true         - platform: gpio     name: "light15"     pin:       pcf8574: pcf8574_hub_out_2       number: 6       mode: OUTPUT       inverted: true         - platform: gpio     name: "light16"     pin:       pcf8574: pcf8574_hub_out_2       number: 7       mode: OUTPUT       inverted: true       binary_sensor:   - platform: gpio     name: "input1"     pin:       pcf8574: pcf8574_hub_in_1       number: 0       mode: INPUT       inverted: true   - platform: gpio     name: "input2"     pin:       pcf8574: pcf8574_hub_in_1       number: 1       mode: INPUT       inverted: true   - platform: gpio     name: "input3"     pin:       pcf8574: pcf8574_hub_in_1       number: 2       mode: INPUT       inverted: true   - platform: gpio     name: "input4"     pin:       pcf8574: pcf8574_hub_in_1       number: 3       mode: INPUT       inverted: true   - platform: gpio     name: "input5"     pin:       pcf8574: pcf8574_hub_in_1       number: 4       mode: INPUT       inverted: true   - platform: gpio     name: "input6"     pin:       pcf8574: pcf8574_hub_in_1       number: 5       mode: INPUT       inverted: true   - platform: gpio     name: "input7"     pin:       pcf8574: pcf8574_hub_in_1       number: 6       mode: INPUT       inverted: true   - platform: gpio     name: "input8"     pin:       pcf8574: pcf8574_hub_in_1       number: 7       mode: INPUT       inverted: true   - platform: gpio     name: "input9"     pin:       pcf8574: pcf8574_hub_in_2       number: 0       mode: INPUT       inverted: true   - platform: gpio     name: "input10"     pin:       pcf8574: pcf8574_hub_in_2       number: 1       mode: INPUT       inverted: true   - platform: gpio     name: "input11"     pin:       pcf8574: pcf8574_hub_in_2       number: 2       mode: INPUT       inverted: true   - platform: gpio     name: "input12"     pin:       pcf8574: pcf8574_hub_in_2       number: 3       mode: INPUT       inverted: true   - platform: gpio     name: "input13"     pin:       pcf8574: pcf8574_hub_in_2       number: 4       mode: INPUT       inverted: true   - platform: gpio     name: "input14"     pin:       pcf8574: pcf8574_hub_in_2       number: 5       mode: INPUT       inverted: true   - platform: gpio     name: "input15"     pin:       pcf8574: pcf8574_hub_in_2       number: 6       mode: INPUT       inverted: true   - platform: gpio     name: "input16"     pin:       pcf8574: pcf8574_hub_in_2       number: 7       mode: INPUT       inverted: true tuya_iot:   id: tuya_iot_component   product_id: ik0eqq501bf46nha   device_id: 262d9640f32b66500bc6rc   device_secret: naxkmeGO58QURf3Q   region: eu   on_event:     - event_name: property/set       then:         - lambda: !lambda |-               // Append the required switch in switch_map to respond to commands issued by Tuya.               static std::map switch_map {                 { 1, id(light1) },                 { 2, id(light2) },               };               bool is_target_output = false;               bool output_state = false;               int output_number = 0;               // Modify this number 2 to match the number of switches in the above switch_map.               for (int i = 1; i <= 2; i++) {                 String key = "output" + String(i);                 if (x.containsKey("data") && x["data"].containsKey(key.c_str())) {                   is_target_output = true;                   output_state = x["data"][key.c_str()];                   output_number = i;                   break;                 }               }               if (is_target_output) {                 auto iterator = switch_map.find(output_number);                 if (iterator != switch_map.end()) {                   auto sw = iterator->second;                   if (output_state) {                     sw->turn_on();                   } else {                     sw->turn_off();                   }                 }               }               bool is_target_all_on = false;               bool all_on_state = false;               if (x.containsKey("data") && x["data"].containsKey("all_on")) {                 is_target_all_on = true;                 all_on_state = x["data"]["all_on"];               }               if (is_target_all_on) {                 if (all_on_state) {                   for(const auto& pair : switch_map) {                     auto sw = pair.second;                     sw->turn_on();                   }                 }               }               bool is_target_all_off = false;               bool all_off_state = false;               if (x.containsKey("data") && x["data"].containsKey("all_off")) {                 is_target_all_off = true;                 all_off_state = x["data"]["all_off"];               }               if (is_target_all_off) {                 if (all_off_state) {                   for(const auto& pair : switch_map) {                     auto sw = pair.second;                     sw->turn_off();                   }                 }               } # Enable logging logger: # Enable Home Assistant API api: sensor:   - platform: ultrasonic     echo_pin: GPIO32     trigger_pin: GPIO33     name: "Water Tank Level"     update_interval: 1s     unit_of_measurement: L     accuracy_decimals: 0       filters:       - filter_out: nan       - multiply: -100       - offset: 150       - lambda: return x * (+100) - 150;             remote_receiver:   pin: GPIO2   dump:     - rc_switch   tolerance: 50%   filter: 250us   idle: 4ms   buffer_size: 2kb   remote_transmitter:   pin: GPIO15   # RF uses a 100% carrier signal   carrier_duty_percent: 100%