@Gurumir @rev.antun @LutzHB @Frank501 @noschvie @phettsack
Hallo, hier eine kleine Rückmeldung zu meinem Projekt,
Schalten des Conson CP24 Relais Moduls mit Status Rückmeldung
Aktuel hängt am ESP8266 ein MCP23017 GPIO-Expander , somit können 8 Relais geschaltet werden und 8 Status ausgewertet werden, dies genügt also um 2 CP24 Module zu bedienen.
Die ESP-Home Yaml für den ESP8266 lautet nun wie folgt:
esphome:
name: "nodemcu-conson"
friendly_name: NodeMCU-Conson
esp8266:
board: nodemcuv2
logger:
web_server:
api:
encryption:
key: "fa3pXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ota:
- platform: esphome
password: "aa9YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
- ssid: !secret wifi_ssid2
password: !secret wifi_password2
ap:
ssid: "Nodemcu Fallback Hotspot"
password: "PytZZZZZZZZZZZZZZ"
captive_portal:
# I2C & MCP
i2c:
sda: GPIO04
scl: GPIO05
frequency: 400kHz
scan: false
mcp23017:
- id: mcp23017_01
address: 0x20
# 8 Relais (B0..B7) – intern, kein HA-Icon
switch:
- platform: gpio
id: rl_1
internal: true
pin: { mcp23xxx: mcp23017_01, number: 8, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_2
internal: true
pin: { mcp23xxx: mcp23017_01, number: 9, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_3
internal: true
pin: { mcp23xxx: mcp23017_01, number: 10, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_4
internal: true
pin: { mcp23xxx: mcp23017_01, number: 11, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_5
internal: true
pin: { mcp23xxx: mcp23017_01, number: 12, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_6
internal: true
pin: { mcp23xxx: mcp23017_01, number: 13, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_7
internal: true
pin: { mcp23xxx: mcp23017_01, number: 14, mode: { output: true }, inverted: false }
- platform: gpio
id: rl_8
internal: true
pin: { mcp23xxx: mcp23017_01, number: 15, mode: { output: true }, inverted: false }
# 8 Buttons (Taster-Impulse, 100 ms)
button:
- platform: template
name: "Taster Licht 1"
on_press:
- switch.turn_on: rl_1
- delay: 100ms
- switch.turn_off: rl_1
- platform: template
name: "Taster Licht 2"
on_press:
- switch.turn_on: rl_2
- delay: 100ms
- switch.turn_off: rl_2
- platform: template
name: "Taster Licht 3"
on_press:
- switch.turn_on: rl_3
- delay: 100ms
- switch.turn_off: rl_3
- platform: template
name: "Taster Licht 4"
on_press:
- switch.turn_on: rl_4
- delay: 100ms
- switch.turn_off: rl_4
- platform: template
name: "Taster Licht 5"
on_press:
- switch.turn_on: rl_5
- delay: 100ms
- switch.turn_off: rl_5
- platform: template
name: "Taster Licht 6"
on_press:
- switch.turn_on: rl_6
- delay: 100ms
- switch.turn_off: rl_6
- platform: template
name: "Taster Licht 7"
on_press:
- switch.turn_on: rl_7
- delay: 100ms
- switch.turn_off: rl_7
- platform: template
name: "Taster Licht 8"
on_press:
- switch.turn_on: rl_8
- delay: 100ms
- switch.turn_off: rl_8
# 8 Rückmelder (A0..A7) – Status für das Färben der Buttons
binary_sensor:
- platform: gpio
id: fb_1
name: "Status Licht 1"
pin: { mcp23xxx: mcp23017_01, number: 0, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_2
name: "Status Licht 2"
pin: { mcp23xxx: mcp23017_01, number: 1, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_3
name: "Status Licht 3"
pin: { mcp23xxx: mcp23017_01, number: 2, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_4
name: "Status Licht 4"
pin: { mcp23xxx: mcp23017_01, number: 3, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_5
name: "Status Licht 5"
pin: { mcp23xxx: mcp23017_01, number: 4, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_6
name: "Status Licht 6"
pin: { mcp23xxx: mcp23017_01, number: 5, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_7
name: "Status Licht 7"
pin: { mcp23xxx: mcp23017_01, number: 6, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
- platform: gpio
id: fb_8
name: "Status Licht 8"
pin: { mcp23xxx: mcp23017_01, number: 7, mode: { input: true, pullup: true }, inverted: true }
filters: [ delayed_on: 20ms, delayed_off: 20ms ]
In HA habe ich folgendes DashBoard (falls man das so nennt) per Yaml erstellt. Es zeigt 8 Glühbirnen-Buttons welche bei ausgeschaltetem Relais des CP24 grau sind , bei geschaltetem Relais den Button dann orange färben:
views:
- title: Lichter
path: lichter
icon: mdi:lightbulb-group
type: panel
cards:
- type: grid
columns: 4
square: false
cards:
- type: button
name: Licht 1
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_1
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_1
- type: button
name: Licht 2
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_2
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_2
- type: button
name: Licht 3
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_3
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_3
- type: button
name: Licht 4
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_4
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_4
- type: button
name: Licht 5
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_5
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_5
- type: button
name: Licht 6
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_6
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_6
- type: button
name: Licht 7
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_7
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_7
- type: button
name: Licht 8
icon: mdi:lightbulb
entity: binary_sensor.nodemcu_conson_status_licht_8
state_color: true
show_state: false
tap_action:
action: call-service
service: button.press
target:
entity_id: button.nodemcu_conson_taster_licht_8

