esphome: name: a8sv2 platform: ESP32 board: esp32dev # 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 # Example configuration entry pcf8574: - id: 'pcf8574_hub_out_1' # for output channel 1-8 address: 0x24 - id: 'pcf8574_hub_in_1' # for input channel 1-8 address: 0x22 # Individual outputs switch: - platform: gpio name: "a8s_light1" id: a8s_light1 pin: pcf8574: pcf8574_hub_out_1 number: 0 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,1,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,1,0,OK"); - platform: gpio name: "a8s_light2" id: a8s_light2 pin: pcf8574: pcf8574_hub_out_1 number: 1 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,2,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,2,0,OK"); - platform: gpio name: "a8s_light3" id: a8s_light3 pin: pcf8574: pcf8574_hub_out_1 number: 2 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,3,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,3,0,OK"); - platform: gpio name: "a8s_light4" id: a8s_light4 pin: pcf8574: pcf8574_hub_out_1 number: 3 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,4,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,4,0,OK"); - platform: gpio name: "a8s_light5" id: a8s_light5 pin: pcf8574: pcf8574_hub_out_1 number: 4 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,5,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,5,0,OK"); - platform: gpio name: "a8s_light6" id: a8s_light6 pin: pcf8574: pcf8574_hub_out_1 number: 5 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,6,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,6,0,OK"); - platform: gpio name: "a8s_light7" id: a8s_light7 pin: pcf8574: pcf8574_hub_out_1 number: 6 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,7,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,7,0,OK"); - platform: gpio name: "a8s_light8" id: a8s_light8 pin: pcf8574: pcf8574_hub_out_1 number: 7 mode: OUTPUT inverted: true on_turn_on: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,8,1,OK"); on_turn_off: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-SET-255,8,0,OK"); binary_sensor: - platform: gpio name: "a8s_input1" publish_initial_state: true pin: pcf8574: pcf8574_hub_in_1 number: 0 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,1,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,1,0,OK"); - platform: gpio name: "a8s_input2" pin: pcf8574: pcf8574_hub_in_1 number: 1 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,2,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,2,0,OK"); - platform: gpio name: "a8s_input3" pin: pcf8574: pcf8574_hub_in_1 number: 2 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,3,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,3,0,OK"); - platform: gpio name: "a8s_input4" pin: pcf8574: pcf8574_hub_in_1 number: 3 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,4,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,4,0,OK"); - platform: gpio name: "a8s_input5" pin: pcf8574: pcf8574_hub_in_1 number: 4 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,5,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,5,0,OK"); - platform: gpio name: "a8s_input6" pin: pcf8574: pcf8574_hub_in_1 number: 5 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,6,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,6,0,OK"); - platform: gpio name: "a8s_input7" pin: pcf8574: pcf8574_hub_in_1 number: 6 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,7,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,7,0,OK"); - platform: gpio name: "a8s_input8" pin: pcf8574: pcf8574_hub_in_1 number: 7 mode: INPUT inverted: true on_press: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,8,1,OK"); on_release: - lambda: !lambda |- id(loxone1).send_string_data("RELAY-GET_INPUT-255,8,0,OK"); sensor: - platform: adc pin: 36 name: "A8S A1 Voltage" update_interval: 5s attenuation: 11db filters: - lambda: if (x >= 3.11) { return x * 1.60256; } else if (x <= 0.15) { return 0; } else { return x * 1.51; } - platform: adc pin: 34 name: "A8S A2 Voltage" update_interval: 5s attenuation: 11db filters: # - multiply: 1.51515 - lambda: if (x >= 3.11) { return x * 1.60256; } else if (x <= 0.15) { return 0; } else { return x * 1.51; } - platform: adc pin: 35 name: "A8S A3 Current" update_interval: 5s unit_of_measurement: mA attenuation: 11db filters: - multiply: 6.66666666 - platform: adc pin: 39 name: "A8S A4 Current" update_interval: 5s unit_of_measurement: mA attenuation: 11db filters: - multiply: 6.66666666 # Enable logging logger: # level: INFO # baud_rate: 9600 # Enable Home Assistant API api: external_components: - source: type: git url: https://github.com/hzkincony/esphome-loxone ref: v1.2.0 loxone: id: loxone1 protocol: udp # tcp or udp loxone_ip: "192.168.3.109" loxone_port: 9999 listen_port: 8888 # esp32 will listen on this port delimiter: "\n" send_buffer_length: 64 on_string_data: - logger.log: format: "on_string_data, data=%s" args: [ data.c_str() ] - lambda: !lambda |- if (data == "RELAY-SET-255,1,1") { id(a8s_light1).turn_on(); } else if (data == "RELAY-SET-255,1,0") { id(a8s_light1).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,2,1") { id(a8s_light2).turn_on(); } else if (data == "RELAY-SET-255,2,0") { id(a8s_light2).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,3,1") { id(a8s_light3).turn_on(); } else if (data == "RELAY-SET-255,3,0") { id(a8s_light3).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,4,1") { id(a8s_light4).turn_on(); } else if (data == "RELAY-SET-255,4,0") { id(a8s_light4).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,5,1") { id(a8s_light5).turn_on(); } else if (data == "RELAY-SET-255,5,0") { id(a8s_light5).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,6,1") { id(a8s_light6).turn_on(); } else if (data == "RELAY-SET-255,6,0") { id(a8s_light6).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,7,1") { id(a8s_light7).turn_on(); } else if (data == "RELAY-SET-255,7,0") { id(a8s_light7).turn_off(); } - lambda: !lambda |- if (data == "RELAY-SET-255,8,1") { id(a8s_light8).turn_on(); } else if (data == "RELAY-SET-255,8,0") { id(a8s_light8).turn_off(); } web_server: port: 80