Skip to content

Commit

Permalink
Update Number State based on current settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 24, 2024
1 parent b2ec0d7 commit 3a99a81
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 33 deletions.
108 changes: 75 additions & 33 deletions firmware/addons/memory-utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ tc_bus:
on_read_memory_timeout:
- logger.log: "Failed to read Memory"

# Read Memory before reading and writing
button:
- platform: template
name: "Read Memory"
on_press:
- tc_bus.read_memory:

number:
- platform: template
name: "Ringtone volume"
optimistic: true
min_value: 0
max_value: 7
step: 1
lambda: !lambda "return id(tc_bus_intercom)->get_settings().ringtone_volume;"
update_interval: 10s
set_action:
- tc_bus.update_setting:
type: volume_ringtone
Expand All @@ -29,49 +38,82 @@ number:
min_value: 0
max_value: 7
step: 1
lambda: !lambda "return id(tc_bus_intercom)->get_settings().handset_volume;"
update_interval: 10s
set_action:
- tc_bus.update_setting:
type: volume_handset
value: !lambda "return x;"

select:
- platform: template
name: "Ringtone: Floor Call"
optimistic: true
min_value: 0
max_value: 12
step: 1
lambda: !lambda "return id(tc_bus_intercom)->get_settings().floor_call_ringtone;"
update_interval: 10s
set_action:
- tc_bus.update_setting:
type: ringtone_floor_call
value: !lambda "return x;"

- platform: template
name: "Ringtone: Door Call"
optimistic: true
options:
- "Ringtone 1"
- "Ringtone 2"
- "Ringtone 3"
- "Ringtone 4"
- "Ringtone 5"
- "Ringtone 6"
- "Ringtone 7"
- "Ringtone 8"
- "Ringtone 9"
- "Ringtone 10"
- "Ringtone 11"
- "Ringtone 12"
initial_option: "Ringtone 1"
min_value: 0
max_value: 12
step: 1
lambda: !lambda "return id(tc_bus_intercom)->get_settings().door_call_ringtone;"
update_interval: 10s
set_action:
- tc_bus.update_setting:
type: ringtone_door_call
value: !lambda |-
std::string str = x;
std::vector<std::string> v;
char * token;
char seps[] = " ";
token = strtok (&str[1],seps);
while (token != NULL)
{
v.push_back(token);
token = strtok (NULL, seps);
}
return std::stoi(v[1].c_str());
value: !lambda "return x;"

button:
- platform: template
name: "Read Memory"
on_press:
- tc_bus.read_memory:
name: "Ringtone: Internal Call"
optimistic: true
min_value: 0
max_value: 12
step: 1
lambda: !lambda "return id(tc_bus_intercom)->get_settings().internal_call_ringtone;"
update_interval: 10s
set_action:
- tc_bus.update_setting:
type: ringtone_internal_call
value: !lambda "return x;"

#select:
# - platform: template
# name: "Ringtone: Door Call"
# optimistic: true
# options:
# - "Ringtone 1"
# - "Ringtone 2"
# - "Ringtone 3"
# - "Ringtone 4"
# - "Ringtone 5"
# - "Ringtone 6"
# - "Ringtone 7"
# - "Ringtone 8"
# - "Ringtone 9"
# - "Ringtone 10"
# - "Ringtone 11"
# - "Ringtone 12"
# initial_option: "Ringtone 1"
# set_action:
# - tc_bus.update_setting:
# type: ringtone_door_call
# value: !lambda |-
# std::string str = x;
# std::vector<std::string> v;
# char * token;
# char seps[] = " ";
# token = strtok (&str[1],seps);
# while (token != NULL)
# {
# v.push_back(token);
# token = strtok (NULL, seps);
# }
# return std::stoi(v[1].c_str());
1 change: 1 addition & 0 deletions firmware/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ external_components:

# Setup TC:BUS Component
tc_bus:
id: tc_bus_intercom
event: "doorman"
hardware_version:
name: "Hardware"
Expand Down

0 comments on commit 3a99a81

Please sign in to comment.