fixing garten_bus_controller

This commit is contained in:
Martin Bauer 2023-08-29 22:32:03 +02:00
parent 50779acee3
commit a22a1dbd8a
3 changed files with 68 additions and 15 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/venv

View File

@ -25,10 +25,10 @@ external_components:
ref: master
external_components:
- source:
type: local
path: my_components
#external_components:
# - source:
# type: local
# path: my_components
#wifi:
# ssid: "WLAN"
@ -75,6 +75,7 @@ modbus_controller:
- modbus_id: "modbus_relays"
id: "relayboard32"
address: 0x1
update_interval: "60s"
- modbus_id: "modbus_relays"
id: "relayboard8_with_inputs"
address: 0x2
@ -91,37 +92,81 @@ packages:
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch01"
name: "ventil-beete-nordwest"
dev_addr: 0x1
register_addr: 0x01
relay02: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch02"
name: "ventil-beet-west"
dev_addr: 0x1
register_addr: 0x02
relay03: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch03"
name: "ventil-sprinkler-westen"
dev_addr: 0x1
register_addr: 0x03
relay16: !include
#relay04: !include
# file: "modbus_relay.yaml"
# vars:
# cid: relayboard32
# name: "ventil-gartenhaus-kein-rohr-angeschlossen"
# dev_addr: 0x1
# register_addr: 0x04
relay05: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch16"
name: "ventil-sprinkler-sud"
dev_addr: 0x1
register_addr: 0x0f
relay17: !include
register_addr: 0x05
#relay06: !include
# file: "modbus_relay.yaml"
# vars:
# cid: relayboard32
# name: "ventil-gartenhaus-kein-ventil-angeschlossen"
# dev_addr: 0x1
# register_addr: 0x06
relay07: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch17"
name: "ventil-brunnen-in-zisterne"
dev_addr: 0x1
register_addr: 0x10
register_addr: 0x07
#--- obere reihe
relay29: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed3"
dev_addr: 0x1
register_addr: 29
relay30: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed2"
dev_addr: 0x1
register_addr: 30
relay31: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed1"
dev_addr: 0x1
register_addr: 31
relay32: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed-off"
dev_addr: 0x1
register_addr: 32
# ------------ Relays of 8-Relay board ----
b2relay1: !include
file: "modbus_relay.yaml"

View File

@ -4,7 +4,8 @@ switch:
modbus_controller_id: ${cid}
name: ${name}
register_type: holding
address: ${dev_addr}
address: ${register_addr}
force_new_range: true
write_lambda: |-
bool open = (x == 1);
payload.push_back(${dev_addr}); // device address
@ -13,4 +14,10 @@ switch:
payload.push_back(${register_addr}); //
payload.push_back(open ? 0x01 : 0x02); // Command
payload.push_back(0x00);
return true;
return open;
#lambda: |-
# if(item->start_address == 0x07)
# {
# ESP_LOGW("relay_lambda", "addr %d | x=%d , (%d, %d)", item->start_address, x, data[item->offset + 0], data[item->offset + 1]);
# }
# return (x == 1);