Skip to content

Commit

Permalink
Change Setup Mode logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 18, 2024
1 parent ba0c96a commit 02c6deb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
4 changes: 2 additions & 2 deletions components/tcs_intercom/tcs_intercom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ namespace esphome
// Update Door Readiness Status
if (cmd_data.type == COMMAND_TYPE_START_TALKING_DOOR_STATION) {
bool door_readiness_state = (command & (1 << 8)) != 0;
ESP_LOGD(TAG, "Door readiness: %d", door_readiness_state);
ESP_LOGD(TAG, "Door readiness: %s", YESNO(door_readiness_state));
if (this->door_readiness_ != nullptr) {
this->door_readiness_->publish_state(door_readiness_state);
}
} else if (cmd_data.type == COMMAND_TYPE_END_OF_DOOR_READINESS) {
ESP_LOGD(TAG, "Door readiness: %d", false);
ESP_LOGD(TAG, "Door readiness: %s", YESNO(false));
if (this->door_readiness_ != nullptr) {
this->door_readiness_->publish_state(false);
}
Expand Down
60 changes: 26 additions & 34 deletions firmware/addons/interactive-setup.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
# Interactive Command Setup Addon

globals:
- id: command_setup_mode
type: bool
restore_value: yes
initial_value: "true"

button:
switch:
- platform: template
id: doorman_interactive_setup_start
name: "Interactive Setup: Start"
icon: mdi:cog-play
entity_category: CONFIG
on_press:
- globals.set:
id: command_setup_mode
value: "true"
name: Setup Mode
icon: mdi:cog
id: doorman_setup_mode
restore_mode: RESTORE_DEFAULT_ON
optimistic: true
on_turn_on:
- script.execute: update_led

- platform: template
id: doorman_interactive_setup_cancel
name: "Interactive Setup: Cancel"
icon: mdi:cog-stop
entity_category: CONFIG
on_press:
- globals.set:
id: command_setup_mode
value: "false"
on_turn_off:
- script.execute: update_led

# Extend TCS Intercom Component
tcs_intercom:
on_command_action:
# If no second door station id is set, wait for one
- if:
condition:
- lambda: return id(command_setup_mode) == true && (x.type == COMMAND_TYPE_FLOOR_CALL || x.type == COMMAND_TYPE_DOOR_CALL);
- lambda: return id(second_door_station_id) == 0 && (x.type == COMMAND_TYPE_DOOR_CALL || x.type == COMMAND_TYPE_OPEN_DOOR) && x.address != 0;
then:
- lambda: |-
// Save serial number
id(intercom_serial_number) = x.serial_number;
- globals.set:
id: second_door_station_id
value: !lambda "return x.address;"

# Setup mode: Wait for Floor or Door Call
- if:
condition:
- switch.is_on: doorman_setup_mode
- lambda: "return x.type == COMMAND_TYPE_FLOOR_CALL || x.type == COMMAND_TYPE_DOOR_CALL;"
then:
- globals.set:
id: command_setup_mode
value: "false"
id: intercom_serial_number
value: !lambda "return x.serial_number;"

- switch.turn_off: doorman_setup_mode

- light.turn_on:
id: doorman_rgb_status_led
Expand All @@ -56,14 +48,14 @@ tcs_intercom:
- script.execute: update_led

- logger.log: Setup done



script:
- id: !extend update_led
then:
- if:
condition:
- lambda: |-
return id(command_setup_mode) == true;
- switch.is_on: doorman_setup_mode
then:
- light.turn_on:
id: doorman_rgb_status_led
Expand Down
2 changes: 1 addition & 1 deletion firmware/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ globals:
- id: second_door_station_id
type: int
restore_value: true
initial_value: '1'
initial_value: '0'


# Board Setup
Expand Down

0 comments on commit 02c6deb

Please sign in to comment.