{{#Name=Multi Feature}} {{#Description=Displays features from multiple devices}} {{#Version=1.0}} {{#Author=HomeSeer}} {{dbs=dashboards_ref}} {{widget_id=queries['widget_id']}} {{if widget_id==null}} {{widget_id=var1}} {{end}} {{w=widget_by_id widget_id}} {{id_unique=string.replace w.id '-' ''}} {{# check if this is the first time this card has been run. If not items have been saved, its the first time }} {{if (array.size (get_saved_values w.id))==0 first_run=true else first_run=false end}} {{#get all the reference ID's used on this card}} {{ values=get_saved_values widget_id }} {{refs=''}} {{for key in values if key.key | string.starts_with 'save_feature' refs=refs | string.append key.value | string.append ',' end end}}
{{#See if all the controls are ON}} {{#key.value is device ref}} {{#key.key is the name of the saved variable, always starts with "save_"}} {{all_on_checked='checked'}} {{#assume all are on}} {{for key in values if key.key | string.starts_with 'save_feature' if is_off key.value all_on_checked='' end end end}} {{#get all saved values for easy reference}} {{# arrays that hold settings for the autogenerated settings dialog. These are filled by calling get_value }} {{current_values=[]}} {{save_names=[]}} {{titles=[]}} {{control_types=[]}} {{# function to get a saved value and return the value or the default value}} {{# function parameters: $0=save name, $1=default value, $2=control name for settings dialog, $3=control type }} {{index=0}} {{func get_value v=get_saved_value $0 widget_id if first_run v=$1 end current_values[index]=v save_names[index]=$0 titles[index]=$2 control_types[index]=$3 index=index+1 ret v end}} {{title=get_value 'save_title' 'Change Me' 'Title' 'text'}} {{title_size=get_value 'save_title_size' '18' 'Title Size' 'text'}} {{title_color=get_value 'save_title_color' 'black' 'Title Color' 'color'}} {{feature_size=get_value 'save_feature_size' '14' 'Feature Size' 'text'}} {{feature_color=get_value 'save_feature_color' 'black' 'Feature Color' 'color'}} {{on_off_only_val=get_value 'save_display_on_off_only' 'on' 'On/Off Only' 'toggle'}} {{use_switch_val=get_value 'save_use_switch' 'on' 'Use Switch' 'toggle'}} {{include_location_val=get_value 'save_include_location' '' 'Include Location' 'toggle'}} {{if on_off_only_val=='on' on_off_only=true else on_off_only=false end}} {{if use_switch_val=='on' use_switch=true else use_switch=false end}} {{if include_location_val=='on' include_location=true else include_location=false end}}
{{title}}
{{for key in values}} {{#the saved feature refs are saved under the name 'save_feature_itemREF}} {{if key.key | string.starts_with 'save_feature_item'}} {{dev=device_by_ref key.value}} {{dev_primary=device_by_ref dev.primary_ref}} {{primary_name=dev_primary.name}} {{if include_location}} {{if location1_display_first}} {{loc=dev.location | string.append '-' | string.append dev.location2}} {{else}} {{loc=dev.location2 | string.append '-' | string.append dev.location}} {{end}} {{loc=loc | string.append "-"}} {{else}} {{loc=''}} {{end}} {{pairs=sort_vspairs 3415}} {{for pair in pairs if pair.control_use=='_On' onval=pair.value end if pair.control_use=='_Off' offval=pair.value end end}}
{{if use_switch}}
{{loc}}{{dev.name}}
{{else}}
{{loc}}{{dev.name}}
{{end}}
{{if on_off_only}} {{else}} {{row1 = controls_row key.value 1 use_switch }} {{if row1 != ''}}
{{row1}}
{{end}} {{row2 = controls_row key.value 2 use_switch}} {{if row2 != ''}}
{{row2}}
{{end}} {{row3 = controls_row key.value 3 use_switch}} {{if row3 != ''}}
{{row3}}
{{end}} {{end}} {{end}} {{end}}
{{#if we are not in edit mode, don't bother including the edit mode content}} {{if dbs.edit_mode}} {{# card settings dialog}} {{#this dialog has 2 tabs, one for formatting the card, the other for card content}} {{# w=widget class, dashboard=dashboard name}} {{# w=widget class, dashboard=dashboard name, d=device}} {{#pop-up dialog to select an HS device feature}} {{else}} {{# non edit mode script}} {{end}}