Hi All,
I have a working yaml config using api. Recently, I tried with MQTT (remove api) but I have no idea on how to do that. My searches in the forum only show result with mqtt platform, no where to hint how to use gpio with mqtt.
I tested with MQTT explorer and issue a command for the following switch (see image)
and the light turn on as expected. My code as following
=========================
....
mqtt:
broker: ".......sfdp.net"
username: "mqtt_user"
password: "mqtt_user"
discovery: true
port: 1883
wifi:
networks:
- ssid: "HOME"
password: "ngoc12345"
# Optional manual IP
manual_ip:
static_ip: 192.168.100.133
gateway: 192.168.100.254
subnet: 255.255.255.0
dns1: 8.8.8.8
dns2: 8.8.4.4
i2c:
- id: bus_a
sda: 0
scl: 2
scan: true
pcf8574:
- id: 'pcf8574_hub'
i2c_id: bus_a
address: 0x38
pcf8575: false
binary_sensor:
- platform: gpio
name: "Input_1"
pin:
pcf8574: pcf8574_hub
number: 0
mode: INPUT
inverted: False
on_press:
then:
- switch.toggle: id1
switch:
- platform: gpio
name: "Lamp 1"
id: id1
restore_mode: DISABLED
pin:
pcf8574: pcf8574_hub
# Use pin number P0
number: 4
# One of INPUT or OUTPUT
mode:
output: true
inverted: False
=========================
Please be so kind to guide me on this with thanks.
Best
Ngoc