esphome: name: sonu friendly_name: Sonu's Home includes: - arduino_port_expander.h external_components: - source: type: git url: https://github.com/hzkincony/esphome-tuya-iot ref: v1.2.0 esp32: board: esp32dev framework: type: arduino # Enable logging logger: # Enable Home Assistant API api: encryption: key: "yoMabETScJwzXghE8awMeIkBM7IZPe5tns1eD9CWYMA=" ota: password: "35a82ac15547f6000a1860228af298f4" wifi: networks: - ssid: "TP-Link_9B81" password: "26264752" - ssid: Xiaomi 11i password: wtmwtgdgd0 # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Sonu_Smart_Home" password: "wtmwtgdgd0" captive_portal: # Example configuration entry i2c: - id: bus_a sda: 21 scl: 22 scan: true # define the port expander hub, here we define one with id 'expander1', # but you can define many custom_component: - id: expander1 lambda: |- auto expander = new ArduinoPortExpander(bus_a, 0x08, true); return {expander}; - id: expander2 lambda: |- auto expander = new ArduinoPortExpander(bus_a, 0x09, true); return {expander}; # Example configuration entry pcf8574: - id: 'pcf8574_hub_1' # for input & output channel 1-8 i2c_id: bus_a address: 0x20 pcf8575: true - id: 'pcf8574_hub_2' # for input & output channel 9-16 i2c_id: bus_a address: 0x21 pcf8575: true - id: 'pcf8574_hub_3' # for input & output channel 17-24 i2c_id: bus_a address: 0x22 pcf8575: true - id: 'pcf8574_hub_4' # for input & output channel 25-32 i2c_id: bus_a address: 0x23 pcf8575: true - id: 'pcf8574_hub_5' # for input & output channel 33-40 i2c_id: bus_a address: 0x24 pcf8575: true - id: 'pcf8574_hub_6' # for input & output channel 41-48 i2c_id: bus_a address: 0x25 pcf8575: true - id: 'pcf8574_hub_7' # for input & output channel 41-48 i2c_id: bus_a address: 0x26 pcf8575: true - id: 'pcf8574_hub_8' # for input & output channel 41-48 i2c_id: bus_a address: 0x27 pcf8575: true pca9685: id: 'pca9685_hub' i2c_id: bus_a address: 0x40 frequency: 500 time: - platform: homeassistant id: homeassistant_time output: - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM0" channel: 0 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM1" channel: 1 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM2" channel: 2 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM3" channel: 3 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM4" channel: 4 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM5" channel: 5 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM6" channel: 6 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM7" channel: 7 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM8" channel: 8 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM9" channel: 9 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM10" channel: 10 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM11" channel: 11 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM12" channel: 12 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM13" channel: 13 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM14" channel: 14 - platform: pca9685 pca9685_id: 'pca9685_hub' id: "PWM15" channel: 15 - platform: custom type: binary lambda: |- return {ape_binary_output(expander1, 2), ape_binary_output(expander1, 3), ape_binary_output(expander1, 4), ape_binary_output(expander1, 5), ape_binary_output(expander1, 6), ape_binary_output(expander1, 7), ape_binary_output(expander2, 2), ape_binary_output(expander2, 3), ape_binary_output(expander2, 4), ape_binary_output(expander2, 5), ape_binary_output(expander2, 6), ape_binary_output(expander2, 7) }; outputs: - id: Uno1_1 inverted: true - id: Uno1_2 inverted: true - id: Uno1_3 inverted: true - id: Uno1_4 inverted: true - id: Uno1_5 inverted: true - id: Uno1_6 inverted: true - id: Uno2_1 inverted: true - id: Uno2_2 inverted: true - id: Uno2_3 inverted: true - id: Uno2_4 inverted: true - id: Uno2_5 inverted: true - id: Uno2_6 inverted: true light: - platform: fastled_clockless chipset: WS2812B id: Living_argb_strip pin: 5 num_leds: 300 # Adjust the number of LEDs rgb_order: GRB name: "Living_argb_strip" effects: - addressable_rainbow: ##defined 7 effects styles - addressable_color_wipe: - addressable_scan: - addressable_twinkle: - addressable_random_twinkle: - addressable_fireworks: - addressable_flicker: - platform: fastled_clockless chipset: WS2812B id: TV_argb_strip pin: 13 num_leds: 300 # Adjust the number of LEDs rgb_order: GRB name: "TV_argb_strip" effects: - addressable_rainbow: ##defined 7 effects styles - addressable_color_wipe: - addressable_scan: - addressable_twinkle: - addressable_random_twinkle: - addressable_fireworks: - addressable_flicker: - platform: fastled_clockless chipset: WS2812B id: Bedroom_argb_strip pin: 14 num_leds: 300 # Adjust the number of LEDs rgb_order: GRB name: "Bedroom_argb_strip" effects: - addressable_rainbow: ##defined 7 effects styles - addressable_color_wipe: - addressable_scan: - addressable_twinkle: - addressable_random_twinkle: - addressable_fireworks: - addressable_flicker: - platform: monochromatic name: "Dimmer-1" output: PWM0 - platform: monochromatic name: "Dimmer-2" output: PWM1 - platform: monochromatic name: "Dimmer-3" output: PWM2 - platform: monochromatic name: "Dimmer-4" output: PWM3 - platform: monochromatic name: "Dimmer-5" output: PWM4 - platform: monochromatic name: "Dimmer-6" output: PWM5 - platform: monochromatic name: "Dimmer-7" output: PWM6 - platform: monochromatic name: "Dimmer-8" output: PWM7 - platform: monochromatic name: "Dimmer-9" output: PWM8 - platform: monochromatic name: "Dimmer-10" output: PWM9 - platform: monochromatic name: "Dimmer-11" output: PWM10 - platform: monochromatic name: "Dimmer-12" output: PWM11 - platform: monochromatic name: "Dimmer1_(1-10V)" output: PWM12 gamma_correct: 1 - platform: monochromatic name: "Dimmer2_(1-10V)" output: PWM13 gamma_correct: 1 - platform: monochromatic name: "Dimmer3_(1-10V)" output: PWM14 gamma_correct: 1 - platform: monochromatic name: "Dimmer4_(1-10V)" output: PWM15 gamma_correct: 1 cd74hc4067: - id: cd74hc4067_1 pin_s0: pcf8574: pcf8574_hub_8 number: 6 mode: OUTPUT inverted: true pin_s1: pcf8574: pcf8574_hub_8 number: 7 mode: OUTPUT inverted: true pin_s2: pcf8574: pcf8574_hub_8 number: 14 mode: OUTPUT inverted: true pin_s3: pcf8574: pcf8574_hub_8 number: 15 mode: OUTPUT inverted: true # Example configuration entry sensor: - platform: dht pin: 32 temperature: name: "Living Room Temperature" humidity: name: "Living Room Humidity" update_interval: 60s - platform: dht pin: 33 temperature: name: "Kitchen Temperature" humidity: name: "Kitchen Humidity" update_interval: 60s - platform: dht pin: 2 temperature: name: "Bedroom Temperature" humidity: name: "Bedroom Humidity" update_interval: 60s - platform: adc pin: 36 id: adc36 update_interval: never attenuation: auto - platform: adc name: "Anolg_IN-17" pin: 39 id: adc39 update_interval: 5s attenuation: auto - platform: adc pin: 34 name: "Anolg_IN-18" id: adc34 update_interval: 5s attenuation: auto - platform: adc pin: 35 name: "Anolg_IN-19" id: adc35 update_interval: 5s attenuation: auto - platform: cd74hc4067 name: "Anolg_IN-1" id: anolog_1 number: 0 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-2" id: anolog_2 number: 1 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-3" id: anolog_3 number: 2 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-4" id: anolog_4 number: 3 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-5" id: anolog_5 number: 4 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-6" id: anolog_6 number: 5 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-7" id: anolog_7 number: 6 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-8" id: anolog_8 number: 7 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-9" id: anolog_9 number: 8 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-10" id: anolog_10 number: 9 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-11" id: anolog_11 number: 10 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-12" id: anolog_12 number: 11 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-13" id: anolog_13 number: 12 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-14" id: anolog_14 number: 13 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-15" id: anolog_15 number: 14 sensor: adc36 update_interval: 5s - platform: cd74hc4067 name: "Anolg_IN-16" id: anolog_16 number: 15 sensor: adc36 update_interval: 5s - platform: custom lambda: |- return {ape_analog_input(expander1, 14), ape_analog_input(expander1, 15), ape_analog_input(expander1, 16), ape_analog_input(expander1, 17), ape_analog_input(expander2, 14), ape_analog_input(expander2, 15), ape_analog_input(expander2, 16), ape_analog_input(expander2, 17) }; sensors: - name: Analog A0 id: Uno1_AN_1 filters: # update every 60s - throttle: 60s # LM35 outputs 0.01v per ºC, and 1023 means 3.3 volts - lambda: return x * 330.0 / 1023.0; - name: Analog A1 id: Uno1_AN_2 filters: - throttle: 2s - name: Analog A2 id: Uno1_AN_3 filters: - throttle: 2s - name: Analog A3 id: Uno1_AN_4 filters: - throttle: 2s - name: Analog1 A0 id: Uno2_AN_1 filters: # update every 60s - throttle: 60s # LM35 outputs 0.01v per ºC, and 1023 means 3.3 volts - lambda: return x * 330.0 / 1023.0; - name: Analog1 A1 id: Uno2_AN_2 filters: - throttle: 2s - name: Analog1 A2 id: Uno2_AN_3 filters: - throttle: 2s - name: Analog1 A3 id: Uno2_AN_4 filters: - throttle: 2s # Individual outputs switch: - platform: gpio name: "light1" pin: pcf8574: pcf8574_hub_1 number: 0 mode: OUTPUT inverted: true id: Light1 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output1", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output1", false); - platform: gpio name: "light2" pin: pcf8574: pcf8574_hub_1 number: 1 mode: OUTPUT inverted: true id: Light2 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output2", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output2", false); - platform: gpio name: "light3" pin: pcf8574: pcf8574_hub_1 number: 2 mode: OUTPUT inverted: true id: Light3 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output3", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output3", false); - platform: gpio name: "light4" pin: pcf8574: pcf8574_hub_1 number: 3 mode: OUTPUT inverted: true id: Light4 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output4", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output4", false); - platform: gpio name: "light5" pin: pcf8574: pcf8574_hub_1 number: 4 mode: OUTPUT inverted: true id: Light5 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output5", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output5", false); - platform: gpio name: "light6" pin: pcf8574: pcf8574_hub_1 number: 5 mode: OUTPUT inverted: true id: Light6 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output6", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output6", false); - platform: gpio name: "light7" pin: pcf8574: pcf8574_hub_1 number: 6 mode: OUTPUT inverted: true id: Light7 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output7", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output7", false); - platform: gpio name: "light8" pin: pcf8574: pcf8574_hub_1 number: 7 mode: OUTPUT inverted: true id: Light8 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output8", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output8", false); - platform: gpio name: "light9" pin: pcf8574: pcf8574_hub_2 number: 0 mode: OUTPUT inverted: true id: Light9 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output9", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output9", false); - platform: gpio name: "light10" pin: pcf8574: pcf8574_hub_2 number: 1 mode: OUTPUT inverted: true id: Light10 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output10", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output10", false); - platform: gpio name: "light11" pin: pcf8574: pcf8574_hub_2 number: 2 mode: OUTPUT inverted: true id: Light11 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output11", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output11", false); - platform: gpio name: "light12" pin: pcf8574: pcf8574_hub_2 number: 3 mode: OUTPUT inverted: true id: Light12 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output12", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output12", false); - platform: gpio name: "light13" pin: pcf8574: pcf8574_hub_2 number: 4 mode: OUTPUT inverted: true id: Light13 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output13", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output13", false); - platform: gpio name: "light14" pin: pcf8574: pcf8574_hub_2 number: 5 mode: OUTPUT inverted: true id: Light14 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output14", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output14", false); - platform: gpio name: "light15" pin: pcf8574: pcf8574_hub_2 number: 6 mode: OUTPUT inverted: true id: Light15 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output15", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output15", false); - platform: gpio name: "light16" pin: pcf8574: pcf8574_hub_2 number: 7 mode: OUTPUT inverted: true id: Light16 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output16", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output16", false); - platform: gpio name: "light17" pin: pcf8574: pcf8574_hub_3 number: 0 mode: OUTPUT inverted: true id: Light17 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output17", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output17", false); - platform: gpio name: "light18" pin: pcf8574: pcf8574_hub_3 number: 1 mode: OUTPUT inverted: true id: Light18 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output18", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output18", false); - platform: gpio name: "light19" pin: pcf8574: pcf8574_hub_3 number: 2 mode: OUTPUT inverted: true id: Light19 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output19", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output19", false); - platform: gpio name: "light20" pin: pcf8574: pcf8574_hub_3 number: 3 mode: OUTPUT inverted: true id: Light20 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output20", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output20", false); - platform: gpio name: "light21" pin: pcf8574: pcf8574_hub_3 number: 4 mode: OUTPUT inverted: true id: Light21 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output21", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output21", false); - platform: gpio name: "light22" pin: pcf8574: pcf8574_hub_3 number: 5 mode: OUTPUT inverted: true id: Light22 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output22", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output22", false); - platform: gpio name: "light23" pin: pcf8574: pcf8574_hub_3 number: 6 mode: OUTPUT inverted: true id: Light23 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output23", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output23", false); - platform: gpio name: "light24" pin: pcf8574: pcf8574_hub_3 number: 7 mode: OUTPUT inverted: true id: Light24 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output24", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output24", false); - platform: gpio name: "light25" pin: pcf8574: pcf8574_hub_4 number: 0 mode: OUTPUT inverted: true id: Light25 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output25", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output25", false); - platform: gpio name: "light26" pin: pcf8574: pcf8574_hub_4 number: 1 mode: OUTPUT inverted: true id: Light26 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output26", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output26", false); - platform: gpio name: "light27" pin: pcf8574: pcf8574_hub_4 number: 2 mode: OUTPUT inverted: true id: Light27 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output27", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output27", false); - platform: gpio name: "light28" pin: pcf8574: pcf8574_hub_4 number: 3 mode: OUTPUT inverted: true id: Light28 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output28", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output28", false); - platform: gpio name: "light29" pin: pcf8574: pcf8574_hub_4 number: 4 mode: OUTPUT inverted: true id: Light29 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output29", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output29", false); - platform: gpio name: "light30" pin: pcf8574: pcf8574_hub_4 number: 5 mode: OUTPUT inverted: true id: Light30 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output30", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output30", false); - platform: gpio name: "light31" pin: pcf8574: pcf8574_hub_4 number: 6 mode: OUTPUT inverted: true id: Light31 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output31", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output31", false); - platform: gpio name: "light32" pin: pcf8574: pcf8574_hub_4 number: 7 mode: OUTPUT inverted: true id: Light32 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output32", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output32", false); - platform: gpio name: "light33" pin: pcf8574: pcf8574_hub_5 number: 0 mode: OUTPUT inverted: true id: Light33 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output33", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output33", false); - platform: gpio name: "light34" pin: pcf8574: pcf8574_hub_5 number: 1 mode: OUTPUT inverted: true id: Light34 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output34", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output34", false); - platform: gpio name: "light35" pin: pcf8574: pcf8574_hub_5 number: 2 mode: OUTPUT inverted: true id: Light35 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output35", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output35", false); - platform: gpio name: "light36" pin: pcf8574: pcf8574_hub_5 number: 3 mode: OUTPUT inverted: true id: Light36 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output36", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output36", false); - platform: gpio name: "light37" pin: pcf8574: pcf8574_hub_5 number: 4 mode: OUTPUT inverted: true id: Light37 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output37", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output37", false); - platform: gpio name: "light38" pin: pcf8574: pcf8574_hub_5 number: 5 mode: OUTPUT inverted: true id: Light38 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output38", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output38", false); - platform: gpio name: "light39" pin: pcf8574: pcf8574_hub_5 number: 6 mode: OUTPUT inverted: true id: Light39 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output39", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output39", false); - platform: gpio name: "light40" pin: pcf8574: pcf8574_hub_5 number: 7 mode: OUTPUT inverted: true id: Light40 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output40", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output40", false); - platform: gpio name: "light41" pin: pcf8574: pcf8574_hub_6 number: 0 mode: OUTPUT inverted: true id: Light41 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output41", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output41", false); - platform: gpio name: "light42" pin: pcf8574: pcf8574_hub_6 number: 1 mode: OUTPUT inverted: true id: Light42 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output42", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output42", false); - platform: gpio name: "light43" pin: pcf8574: pcf8574_hub_6 number: 2 mode: OUTPUT inverted: true id: Light43 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output43", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output43", false); - platform: gpio name: "light44" pin: pcf8574: pcf8574_hub_6 number: 3 mode: OUTPUT inverted: true id: Light44 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output44", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output44", false); - platform: gpio name: "light45" pin: pcf8574: pcf8574_hub_6 number: 4 mode: OUTPUT inverted: true id: Light45 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output45", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output45", false); - platform: gpio name: "light46" pin: pcf8574: pcf8574_hub_6 number: 5 mode: OUTPUT inverted: true id: Light46 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output46", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output46", false); - platform: gpio name: "light47" pin: pcf8574: pcf8574_hub_6 number: 6 mode: OUTPUT inverted: true id: Light47 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output47", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output47", false); - platform: gpio name: "light48" pin: pcf8574: pcf8574_hub_6 number: 7 mode: OUTPUT inverted: true id: Light48 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output48", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output48", false); - platform: gpio name: "light49" pin: pcf8574: pcf8574_hub_7 number: 0 mode: OUTPUT inverted: true id: Light49 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output49", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output49", false); - platform: gpio name: "light50" pin: pcf8574: pcf8574_hub_7 number: 1 mode: OUTPUT inverted: true id: Light50 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output50", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output50", false); - platform: gpio name: "light51" pin: pcf8574: pcf8574_hub_7 number: 2 mode: OUTPUT inverted: true id: Light51 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output51", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output51", false); - platform: gpio name: "light52" pin: pcf8574: pcf8574_hub_7 number: 3 mode: OUTPUT inverted: true id: Light52 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output52", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output52", false); - platform: gpio name: "light53" pin: pcf8574: pcf8574_hub_7 number: 4 mode: OUTPUT inverted: true id: Light53 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output53", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output53", false); - platform: gpio name: "light54" pin: pcf8574: pcf8574_hub_7 number: 5 mode: OUTPUT inverted: true id: Light54 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output54", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output54", false); - platform: gpio name: "light55" pin: pcf8574: pcf8574_hub_7 number: 6 mode: OUTPUT inverted: true id: Light55 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output55", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output55", false); - platform: gpio name: "light56" pin: pcf8574: pcf8574_hub_7 number: 7 mode: OUTPUT inverted: true id: Light56 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output56", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output56", false); - platform: gpio name: "light57" pin: pcf8574: pcf8574_hub_8 number: 0 mode: OUTPUT inverted: true id: Light57 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output57", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output57", false); - platform: gpio name: "light58" pin: pcf8574: pcf8574_hub_8 number: 1 mode: OUTPUT inverted: true id: Light58 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output58", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output58", false); - platform: gpio name: "light59" pin: pcf8574: pcf8574_hub_8 number: 2 mode: OUTPUT inverted: true id: Light59 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output59", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output59", false); - platform: gpio name: "light60" pin: pcf8574: pcf8574_hub_8 number: 3 mode: OUTPUT inverted: true id: Light60 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output60", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output60", false); - platform: gpio name: "light61" pin: pcf8574: pcf8574_hub_8 number: 4 mode: OUTPUT inverted: true id: Light61 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output61", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output61", false); - platform: gpio name: "light62" pin: pcf8574: pcf8574_hub_8 number: 5 mode: OUTPUT inverted: true id: Light62 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output62", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output62", false); # UNO Switch Relays - platform: output name: "Uno1 light1" id: Uno1_Light1 output: Uno1_1 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output63", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output63", false); - platform: output name: "Uno1 light2" id: Uno1_Light2 output: Uno1_2 on_turn_on: - lambda: !lambda |- id(tuya_iot_component).property_report("Output64", true); on_turn_off: - lambda: !lambda |- id(tuya_iot_component).property_report("Output64", false); - platform: output name: "Uno1 light3" id: Uno1_Light3 output: Uno1_3 - platform: output name: "Uno1 light4" id: Uno1_Light4 output: Uno1_4 - platform: output name: "Uno1 light5" id: Uno1_Light5 output: Uno1_5 - platform: output name: "Uno1 light6" id: Uno1_Light6 output: Uno1_6 - platform: output name: "Uno2 light1" id: Uno2_Light1 output: Uno2_1 - platform: output name: "Uno2 light2" id: Uno2_Light2 output: Uno2_2 - platform: output name: "Uno2 light3" id: Uno2_Light3 output: Uno2_3 - platform: output name: "Uno2 light4" id: Uno2_Light4 output: Uno2_4 - platform: output name: "Uno2 light5" id: Uno2_Light5 output: Uno2_5 - platform: output name: "Uno2 light6" id: Uno2_Light6 output: Uno2_6 # Individual inputs binary_sensor: - platform: gpio name: "switch input1" pin: pcf8574: pcf8574_hub_1 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light1 - platform: gpio name: "switch input2" pin: pcf8574: pcf8574_hub_1 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light2 - platform: gpio name: "switch input3" pin: pcf8574: pcf8574_hub_1 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light3 - platform: gpio name: "switch input4" pin: pcf8574: pcf8574_hub_1 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light4 - platform: gpio name: "switch input5" pin: pcf8574: pcf8574_hub_1 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light5 - platform: gpio name: "switch input6" pin: pcf8574: pcf8574_hub_1 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light6 - platform: gpio name: "switch input7" pin: pcf8574: pcf8574_hub_1 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light7 - platform: gpio name: "switch input8" pin: pcf8574: pcf8574_hub_1 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light8 - platform: gpio name: "switch input9" pin: pcf8574: pcf8574_hub_2 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light9 - platform: gpio name: "switch input10" pin: pcf8574: pcf8574_hub_2 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light10 - platform: gpio name: "switch input11" pin: pcf8574: pcf8574_hub_2 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light11 - platform: gpio name: "switch input12" pin: pcf8574: pcf8574_hub_2 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light12 - platform: gpio name: "switch input13" pin: pcf8574: pcf8574_hub_2 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light13 - platform: gpio name: "switch input14" pin: pcf8574: pcf8574_hub_2 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light14 - platform: gpio name: "switch input15" pin: pcf8574: pcf8574_hub_2 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light15 - platform: gpio name: "switch input16" pin: pcf8574: pcf8574_hub_2 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light16 - platform: gpio name: "switch input17" pin: pcf8574: pcf8574_hub_3 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light17 - platform: gpio name: "switch input18" pin: pcf8574: pcf8574_hub_3 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light18 - platform: gpio name: "switch input19" pin: pcf8574: pcf8574_hub_3 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light19 - platform: gpio name: "switch input20" pin: pcf8574: pcf8574_hub_3 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light20 - platform: gpio name: "switch input21" pin: pcf8574: pcf8574_hub_3 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light21 - platform: gpio name: "switch input22" pin: pcf8574: pcf8574_hub_3 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light22 - platform: gpio name: "switch input23" pin: pcf8574: pcf8574_hub_3 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light23 - platform: gpio name: "switch input24" pin: pcf8574: pcf8574_hub_3 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light24 - platform: gpio name: "switch input25" pin: pcf8574: pcf8574_hub_4 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light25 - platform: gpio name: "switch input26" pin: pcf8574: pcf8574_hub_4 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light26 - platform: gpio name: "switch input27" pin: pcf8574: pcf8574_hub_4 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light27 - platform: gpio name: "switch input28" pin: pcf8574: pcf8574_hub_4 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light28 - platform: gpio name: "switch input29" pin: pcf8574: pcf8574_hub_4 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light29 - platform: gpio name: "switch input30" pin: pcf8574: pcf8574_hub_4 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light30 - platform: gpio name: "switch input31" pin: pcf8574: pcf8574_hub_4 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light31 - platform: gpio name: "switch input32" pin: pcf8574: pcf8574_hub_4 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light32 - platform: gpio name: "switch input33" pin: pcf8574: pcf8574_hub_5 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light33 - platform: gpio name: "switch input34" pin: pcf8574: pcf8574_hub_5 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light34 - platform: gpio name: "switch input35" pin: pcf8574: pcf8574_hub_5 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light35 - platform: gpio name: "switch input36" pin: pcf8574: pcf8574_hub_5 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light36 - platform: gpio name: "switch input37" pin: pcf8574: pcf8574_hub_5 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light37 - platform: gpio name: "switch input38" pin: pcf8574: pcf8574_hub_5 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light38 - platform: gpio name: "switch input39" pin: pcf8574: pcf8574_hub_5 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light39 - platform: gpio name: "switch input40" pin: pcf8574: pcf8574_hub_5 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light40 - platform: gpio name: "switch input41" pin: pcf8574: pcf8574_hub_6 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light41 - platform: gpio name: "switch input42" pin: pcf8574: pcf8574_hub_6 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light42 - platform: gpio name: "switch input43" pin: pcf8574: pcf8574_hub_6 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light43 - platform: gpio name: "switch input44" pin: pcf8574: pcf8574_hub_6 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light44 - platform: gpio name: "switch input45" pin: pcf8574: pcf8574_hub_6 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light45 - platform: gpio name: "switch input46" pin: pcf8574: pcf8574_hub_6 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light46 - platform: gpio name: "switch input47" pin: pcf8574: pcf8574_hub_6 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light47 - platform: gpio name: "switch input48" pin: pcf8574: pcf8574_hub_6 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light48 - platform: gpio name: "switch input49" pin: pcf8574: pcf8574_hub_7 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light49 - platform: gpio name: "switch input50" pin: pcf8574: pcf8574_hub_7 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light50 - platform: gpio name: "switch input51" pin: pcf8574: pcf8574_hub_7 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light51 - platform: gpio name: "switch input52" pin: pcf8574: pcf8574_hub_7 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light52 - platform: gpio name: "switch input53" pin: pcf8574: pcf8574_hub_7 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light53 - platform: gpio name: "switch input54" pin: pcf8574: pcf8574_hub_7 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light54 - platform: gpio name: "switch input55" pin: pcf8574: pcf8574_hub_7 number: 14 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light55 - platform: gpio name: "switch input56" pin: pcf8574: pcf8574_hub_7 number: 15 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light56 - platform: gpio name: "switch input57" pin: pcf8574: pcf8574_hub_8 number: 8 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light57 - platform: gpio name: "switch input58" pin: pcf8574: pcf8574_hub_8 number: 9 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light58 - platform: gpio name: "switch input59" pin: pcf8574: pcf8574_hub_8 number: 10 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light59 - platform: gpio name: "switch input60" pin: pcf8574: pcf8574_hub_8 number: 11 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light60 - platform: gpio name: "switch input61" pin: pcf8574: pcf8574_hub_8 number: 12 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light61 - platform: gpio name: "switch input62" pin: pcf8574: pcf8574_hub_8 number: 13 mode: INPUT inverted: true publish_initial_state: true on_state: then: - switch.toggle: Light62 - platform: custom lambda: |- return {ape_binary_sensor(expander1, 8), ape_binary_sensor(expander1, 9), ape_binary_sensor(expander1, 10), ape_binary_sensor(expander1, 11), ape_binary_sensor(expander1, 12), ape_binary_sensor(expander1, 13), ape_binary_sensor(expander2, 8), ape_binary_sensor(expander2, 9), ape_binary_sensor(expander2, 10), ape_binary_sensor(expander2, 11), ape_binary_sensor(expander2, 12), ape_binary_sensor(expander2, 13) }; binary_sensors: - id: Uno1_Switch1 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light1 - id: Uno1_Switch2 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light2 - id: Uno1_Switch3 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light3 - id: Uno1_Switch4 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light4 - id: Uno1_Switch5 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light5 - id: Uno1_Switch6 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno1_Light6 - id: Uno2_Switch1 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light1 - id: Uno2_Switch2 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light2 - id: Uno2_Switch3 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light3 - id: Uno2_Switch4 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light4 - id: Uno2_Switch5 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light5 - id: Uno2_Switch6 internal: true # don't show on HA publish_initial_state: true on_state: then: - switch.toggle: Uno2_Light6 tuya_iot: id: tuya_iot_component product_id: euryyq8dhjs3fmz9 device_id: 26f8faa7073c2440ddgaav device_secret: 7PsavXYQtCVM5yHZ region: in # eu, us, eus, weu, in, cn # eu: Central Europe Data Center # us: US West Data Center # eus: US East Data Center # weu: Western Europe Data Center # in: India Data Center # cn: Chinese Data Center 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) }, { 3, id(Light3) }, { 4, id(Light4) }, { 5, id(Light5) }, { 6, id(Light6) }, { 7, id(Light7) }, { 8, id(Light8) }, { 9, id(Light9) }, { 10, id(Light10) }, { 11, id(Light11) }, { 12, id(Light12) }, { 13, id(Light13) }, { 14, id(Light14) }, { 15, id(Light15) }, { 16, id(Light16) }, { 17, id(Light17) }, { 18, id(Light18) }, { 19, id(Light19) }, { 20, id(Light20) }, { 21, id(Light21) }, { 22, id(Light22) }, { 23, id(Light23) }, { 24, id(Light24) }, { 25, id(Light25) }, { 26, id(Light26) }, { 27, id(Light27) }, { 28, id(Light28) }, { 29, id(Light29) }, { 30, id(Light30) }, { 31, id(Light31) }, { 32, id(Light32) }, { 33, id(Light33) }, { 34, id(Light34) }, { 35, id(Light35) }, { 36, id(Light36) }, { 37, id(Light37) }, { 38, id(Light38) }, { 39, id(Light39) }, { 40, id(Light40) }, { 41, id(Light41) }, { 42, id(Light42) }, { 43, id(Light43) }, { 44, id(Light44) }, { 45, id(Light45) }, { 46, id(Light46) }, { 47, id(Light47) }, { 48, id(Light48) }, { 49, id(Light49) }, { 50, id(Light50) }, { 51, id(Light51) }, { 52, id(Light52) }, { 53, id(Light53) }, { 54, id(Light54) }, { 55, id(Light55) }, { 56, id(Light56) }, { 57, id(Light57) }, { 58, id(Light58) }, { 59, id(Light59) }, { 60, id(Light60) }, { 61, id(Light61) }, { 62, id(Light62) }, { 63, id(Uno1_Light1) }, { 64, id(Uno1_Light2) }, }; bool is_target_output = false; bool output_state = false; int output_number = 0; // Modify this number 64 to match the number of switches in the above switch_map. for (int i = 1; i <= 64; 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(); } } }