Witam
Walczę z menu na wyswietlaczu 2004 do wyswietlania odczytanych danych z Wmbus na kilku mieszkaniach. Aktualnie mogę za pomocą encodera i przycisku przechodzic po menu i wracac ale nie wiem jak zmusić wyswietlanie stanu licznika w odpowiednim podmenu. Funkcja return id wyswietla poprawnie tylko adres ip. a potrzebowałby w podmenu informacje " woda zimna" - licznik, " woda ciepla" - licznik. Jak w w drugim przykładzie
esp32:
board: esp32dev
framework:
type: arduino
time:
- platform: sntp
id: time_sntp
timezone: Europe/Berlin
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
# esp32_improv:
# authorizer: none
# To have a "next url" for improv serial
web_server:
port: 80
version: 3
auth:
username: !secret web_server_username
password: !secret web_server_password
external_components:
- source: github://SzczepanLeon/esphome-components@main
# - source: github://SzczepanLeon/esphome-components@2.4.10
# - source: github://SzczepanLeon/esphome-components@3.2.3
refresh: 0d
components: [ wmbus ]
wmbus:
frequency: 868.950
mosi_pin: GPIO23
miso_pin: GPIO19
clk_pin: GPIO18
cs_pin: GPIO15
gdo0_pin: GPIO16
gdo2_pin: GPIO17
# led_blink_time: "1s"
all_drivers: false
sync_mode: True
log_all: True
i2c:
sda: 21
scl: 22
scan: True
frequency: 400kHz
display:
- platform: lcd_pcf8574
dimensions: 20x4
address: 0x27
id: my_lcd
lambda: |-
id(my_lcd_menu).draw();
if (!id(my_lcd_menu).is_active())
it.print("Menu is not active");
# Declare a LCD menu
lcd_menu:
id: my_lcd_menu
display_id: my_lcd
active: true
mode: rotary
on_enter:
then:
lambda: 'ESP_LOGI("display_menu", "root enter");'
on_leave:
then:
lambda: 'ESP_LOGI("display_menu", "root leave");'
items:
- type: menu
text: 'Max'
on_enter:
then:
lambda: 'ESP_LOGI("display_menu", "enter: %s", it->get_text().c_str());'
on_leave:
then:
lambda: 'ESP_LOGI("display_menu", "leave: %s", it->get_text().c_str());'
items:
- type: back
text: 'Back'
- type: label
text: 'tekst'
- type: menu
text: 'Moja'
on_enter:
then:
lambda: 'ESP_LOGI("display_menu", "enter: %s", it->get_text().c_str());'
on_leave:
then:
lambda: 'ESP_LOGI("display_menu", "leave: %s", it->get_text().c_str());'
items:
- type: back
text: 'Back'
- type: menu
text: 'Mieszkanie1'
on_enter:
then:
lambda: 'ESP_LOGI("display_menu", "enter: %s", it->get_text().c_str());'
on_leave:
then:
lambda: 'ESP_LOGI("display_menu", "leave: %s", it->get_text().c_str());'
items:
- type: back
text: 'Back'
- type: label
text: 'lambda z danymi'
- type: menu
text: 'Mieszkanie2'
on_enter:
then:
lambda: 'ESP_LOGI("display_menu", "enter: %s", it->get_text().c_str());'
on_leave:
then:
lambda: 'ESP_LOGI("display_menu", "leave: %s", it->get_text().c_str());'
items:
- type: back
text: 'Back'
- type: label
text: !lambda |-
return id(esp_ip_address).state.c_str();
# return id(some_sensor).state / 100.0;
# Encoder to provide navigation
sensor:
- platform: rotary_encoder
name: Rotary Encoder
id: rotary
pin_a:
number: 25
mode:
input: true
pin_b:
number: 26
mode:
input: true
filters:
debounce: 120ms
on_anticlockwise:
- display_menu.up:
on_clockwise:
- display_menu.down:
- platform: wmbus
meter_id: 0x415F2497
type: izar
sensors:
- name: "woda1 RSSi"
field: "rssi"
accuracy_decimals: 0
unit_of_measurement: "dBm"
device_class: "signal_strength"
state_class: "measurement"
entity_category: "diagnostic"
- name: "woda1"
id: woda1
field: "total"
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: "water"
state_class: "total_increasing"
icon: "mdi:water"
- name: "woda1 poprzedni mies."
field: "last_month_total"
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: "water"
state_class: "total_increasing"
icon: "mdi:water"
- name: "Okres nadawania - Izar"
field: "transmit_period"
accuracy_decimals: 0
unit_of_measurement: "s"
# device_class: "signal_strength"
# state_class: "measurement"
entity_category: "diagnostic"
# A de-bounced GPIO is used to 'click'
binary_sensor:
- platform: gpio
pin:
number: GPIO27
mode: INPUT_PULLUP
inverted: True
name: "Joystick click"
id: joystick_click
filters:
- delayed_on: 10ms
- delayed_off: 10ms
on_press:
- display_menu.enter:
button:
- platform: restart
name: "Restart ESP"
icon: mdi:restart
switch:
- platform: gpio
id: led_wifi
pin: GPIO2
inverted: False
interval:
- interval: 5s # wykonaj co 1 sekundę
then:
if: # jeżeli
condition:
wifi.connected: # połączenie z Wi-Fi
then:
- if:
condition:
api.connected:
then: # jeżeli połączono z Wi-Fi
- switch.turn_on: led_wifi # to włącz LED Wi-Fi
else: # jeśli nie ma połączenia z HA to mrugaj LED Wi-Fi
- switch.turn_on: led_wifi # włącz LED Wi-Fi
- delay: 500ms # odczekaj
- switch.turn_off: led_wifi # wyłącz LED Wi-Fi
- delay: 500ms # odczekaj
else: # jeżeli nie połączono z Wi-Fi (automatycznie z HA również nie)
- switch.turn_off: led_wifi
text_sensor:
- platform: wifi_info
ip_address:
id: esp_ip_address
icon: mdi:ip-network
name: ESP IP Address
address_0:
name: ESP IP Address 0
ssid:
name: ESP Connected SSID
bssid:
name: ESP Connected BSSID
mac_address:
name: ESP Mac Wifi Address
scan_results:
name: ESP Latest Scan Results
dns_address:
name: ESP DNS Address
chodzi mi o to aby w poszczególnych podmenu wyswietlały sie informacje jak np:
display:
- platform: lcd_pcf8574
dimensions: 20x4
address: 0x27
id: lcd
lambda: |-
switch (id(page)){
case 1:
it.print(0, 0, "mieszkanie1");
it.strftime(10, 0, "%d.%m.%Y", id(time_sntp).now());
it.print(0, 2, "Woda Zimna :%.1f m3");
it.print(0, 3, "Woda Ciepla :%.1f m3");
break;
case 2:
it.print(0, 0, "Mieszkanie2");
it.strftime(10, 0, "%d.%m.%Y", id(time_sntp).now());
it.print(0, 2, "Woda Zimna :%.1f m3");
it.print(0, 3, "Woda Ciepla :%.1f m3");
break;
case 3:
it.print(0, 0, "Mieszkanie3");
it.strftime(10, 0, "%d.%m.%Y", id(time_sntp).now());
it.print(0, 2, "Woda Zimna :%.1f m3");
it.print(0, 3, "Woda Ciepla :%.1f m3");
break;
case 4:
it.print(0, 0, "Termin Odczytu");
it.strftime(0, 1, "Czas " "%H:%M ", id(time_sntp).now());
it.strftime(0, 2, "Data " "%d.%m.%Y", id(time_sntp).now());
it.printf(0, 3, "Ip :%s", id(esp_ip_address).state.c_str());
break;
case 5:
it.strftime(0, 1, "Czas " "%H:%M ", id(time_sntp).now());
it.strftime(0, 2, "Data " "%d.%m.%Y", id(time_sntp).now());
it.printf(0, 3, "Ip :%s", id(esp_ip_address).state.c_str());
break;
}
A dokładniej
it.strftime(10, 0, “%d.%m.%Y”, id(time_sntp).now());
it.print(0, 2, “Woda Zimna :%.1f m3”);
it.print(0, 3, “Woda Ciepla :%.1f m3”);
Wiem ze brakuje Id woda1 id woda2 ale chcialem narazie wyswietlic cokolwiek (np.tekst) i pózniej uzupełnić id
Dzięki za pomoc