Aber ich hab das Programm ja schon mal umgeschrieben, das schaff ich auch noch mal.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Immer gernestarbright hat geschrieben: ↑5. Jun 2024 13:10 Ich stelle euch hier mit meinem Fragen sicher auf die Geduldsprobe. Aber so ist das nun mal beim Basteln... Danke dafür!
Du sendest keinen String ("UP"/"DOWN"/"STOP")!starbright hat geschrieben: ↑5. Jun 2024 13:10 Habe ich dich richtig verstanden:
Es gibt für den Rollershutter 1 (in Worten ein) item, auf das kann man dann 0...100 (integer?) oder up/down/stop (string?) senden?
Aber kann so ein Item nicht nur ein Typ sein? (man kann natürlich auch eine Zahl als String senden).
Code: Alles auswählen
if(receivedCommand == UP) // oder
if(receivedCommand.toString == "UP")
Jastarbright hat geschrieben: ↑5. Jun 2024 13:10 Das war dann mein Missverständnis dass es 3 Kanäle geben muss.
Warum oder? Du kannst ganz locker beides gleichzeitig haben. Allerdings gebe ich zu bedenken, dass es meist nur sehr eingeschränkte Wünsche gibt. Man kann sich hier gut an einem der großen Hersteller orientieren, das ist Somfy. Somfy Bedieneinheiten haben drei Tasten. Taste 1: hoch, Taste 2: runter, Taste 3: "my". Der Clou: Fährt der Rollladen, so dient die "my" Taste zum Stoppen der Fahrt. Steht der Rollladen, so wird mit der "my" Taste eine (!) eingelernte Position angefahren. Du kannst davon ausgehen, dass die Entwickler sich zuvor intensiv mit dem Markt beschäftigt habenstarbright hat geschrieben: ↑5. Jun 2024 13:10 Und noch was, das Rollershutter-Icon hat 3 Schaltflachen, eine 0..100% Angaben ist damit nicht möglich. Dann besser einen Slider (wenn man bei den vorgefertigten Cells bleiben will, oder?
Code: Alles auswählen
esphome:
name: moes
bk72xx:
board: generic-bk7231n-qfn32-tuya
logger:
web_server:
captive_portal:
mdns:
#api:
# password: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
password: !secret wifi_ap_password
mqtt:
broker: "192.168.3.20"
id: mqtt_moes_client
on_message:
- topic: moes/pref_pos
qos: 0
then:
lambda: |-
id(pref_pos) = atoi(x.c_str());
ESP_LOGD("main", "pref_pos via mqtt set to %i", id(pref_pos));
button:
- platform: restart
name: Restart
debug:
update_interval: 30s
text_sensor:
- platform: debug
reset_reason:
name: Reset Reason
- platform: libretiny
version:
name: LibreTiny Version
sensor:
- platform: uptime
name: Uptime
globals:
- id: pref_pos
type: int
initial_value: '55'
cover:
- platform: time_based
name: moes1
id: my_cover
open_action:
- switch.turn_on: switch_up
open_duration: 26000ms
close_action:
- switch.turn_on: switch_down
close_duration: 25000ms
stop_action:
- switch.turn_off: switch_up
- switch.turn_off: switch_down
output:
- platform: gpio
id: output_led_up
pin: P14
- platform: gpio
id: output_led_down
pin: P23
- platform: gpio
id: output_led_stop
pin: P8
light:
- platform: binary
id: light_switch_up
output: output_led_up
- platform: binary
id: light_switch_down
output: output_led_down
- platform: binary
id: light_switch_stop
output: output_led_stop
binary_sensor:
- platform: gpio
id: binary_switch_up
pin:
number: P24
inverted: true
mode: INPUT_PULLUP
on_press:
then:
- lambda: |-
ESP_LOGD("main", "cover.current_operation %i", id(my_cover).current_operation);
if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_IDLE) {
// Cover is idle
auto call = id(my_cover).make_call();
call.set_command_open();
call.perform();
ESP_LOGD("main", "cover.open");
} else if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_OPENING) {
// Cover is currently opening
auto call = id(my_cover).make_call();
call.set_command_stop();
call.perform();
ESP_LOGD("main", "already opening: cover.stop");
} else if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_CLOSING) {
// Cover is currently closing
auto call = id(my_cover).make_call();
call.set_command_stop();
call.perform();
ESP_LOGD("main", "cover.stop");
}
- platform: gpio
id: binary_switch_down
pin:
number: P7
inverted: true
mode: INPUT_PULLUP
on_press:
then:
- lambda: |-
ESP_LOGD("main", "cover.current_operation %i", id(my_cover).current_operation);
if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_IDLE) {
// Cover is idle
auto call = id(my_cover).make_call();
call.set_command_close();
call.perform();
ESP_LOGD("main", "idle - cover.close");
} else if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_OPENING) {
// Cover is currently opening
auto call = id(my_cover).make_call();
call.set_command_stop();
call.perform();
ESP_LOGD("main", "already opening - cover.stop");
} else if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_CLOSING) {
// Cover is currently closing
auto call = id(my_cover).make_call();
call.set_command_stop();
call.perform();
ESP_LOGD("main", "closing - cover.stop");
}
- platform: gpio
id: binary_switch_stop
pin:
number: P10
inverted: true
mode: INPUT_PULLUP
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.01s
then:
- logger.log: "Short press detected"
- lambda: |-
ESP_LOGD("main", "stop: cover.current_operation %i", id(my_cover).current_operation);
if (id(my_cover).current_operation == CoverOperation::COVER_OPERATION_IDLE) {
ESP_LOGD("main", "act pos %i -> pref pos %i", int(id(my_cover).position*100), id(pref_pos));
if (abs(int(id(my_cover).position*100) - id(pref_pos))>1) {
char payload[4];
sprintf(payload, "%d", id(pref_pos));
ESP_LOGD("main", "publish mqtt command to pos %s", payload);
id(mqtt_moes_client).publish("moes/cover/moes1/position/command", payload);
} else {
ESP_LOGD("main", "no action needed, already at right pos");
}
} else {
auto call = id(my_cover).make_call();
call.set_command_stop();
call.perform();
ESP_LOGD("main", "pressed stop while running - cover.stop");
}
- timing:
- ON for 1s to 3s
then:
- logger.log: "Long press detected"
# to be done: disable / enable timings
- light.toggle: light_switch_stop
- timing:
- ON for at least 3s
then:
- logger.log: "Very long press detected"
- lambda: |-
id(pref_pos) = int(id(my_cover).position*100 + 0.5);
ESP_LOGD("main", "set new pref_pos %i",id(pref_pos));
switch:
- platform: gpio
id: switch_up
name: Relay up
pin: P6
restore_mode: RESTORE_DEFAULT_OFF
interlock: [switch_down]
on_turn_on:
- light.turn_on: light_switch_up
on_turn_off:
- light.turn_off: light_switch_up
- platform: gpio
id: switch_down
name: Relay down
pin: P9
restore_mode: RESTORE_DEFAULT_OFF
interlock: [switch_up]
on_turn_on:
- light.turn_on: light_switch_down
on_turn_off:
- light.turn_off: light_switch_down
status_led:
pin: P26
time:
- platform: sntp
id: sntp_time
servers: 192.168.3.1
on_time:
# Every morning on weekdays
- days_of_week: MON-FRI
hours: 06
minutes: 30
seconds: 0
then:
- switch.toggle: switch_up
# Every evening on weekdays
- days_of_week: MON-FRI
hours: 21
minutes: 00
seconds: 0
then:
- switch.toggle: switch_down
# Every morning on weekends
- days_of_week: SAT,SUN
hours: 8
minutes: 00
seconds: 0
then:
- switch.toggle: switch_up
# Every evening on weekends
- days_of_week: SAT,SUN
hours: 21
minutes: 30
seconds: 0
then:
- switch.toggle: switch_down
Code: Alles auswählen
globals:
- id: pref_pos
type: int
restore_value: yes
initial_value: '55'
- id: timer_active
type: bool
restore_value: yes
initial_value: 'true'