{{#Name=Test Card}} {{#Description=Displays text}} {{#Version=1.0}} {{#Author=HomeSeer}} {{#SaveList=save_text_size,save_text_color,save_text_bold}} {{#https://codepen.io/kaolay/pen/ozZovw}} {{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}} {{# To simplify custom controls, the settings dialog that holds settings is auto generated }} {{# To have your persistent settings saved and restored automatically, add them below in the section that calls "get_value" }} {{# storage arrays for saved value, save name, dialog label, control type }} {{# value: The value that is saved for a particular item, such as a display label, color, font size, etc. }} {{# save name: The name used to save the persistent value. All saved names must start with "save_" }} {{# dialog label: The dialog for saving values is auto generated so this is the label that is displayed for the item such as "Color"}} {{# control_type: The type of control used to configure the item. Control types supported here are: }} {{# text: a simple text box for entering text such as a label }} {{# color: allows for entry of a specific HTML color like #000000 and also displays a button that displays a color picker }} {{# toggle: displays a toggle switch for items that support "enabled/disabled" or On/Off }} {{# arrays that hold settings for the autogenerated settings dialog. These are filled by calling get_value }} {{current_values=[]}} {{save_names=[]}} {{titles=[]}} {{control_types=[]}} {{sections=[]}} {{# 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}} {{if w.height==0}} {{#first time loading, set a default height for the card}} {{save_widget_width_height 0 100 widget_id}} {{#since the widget was changed, we need to load it again}} {{w=widget_by_id widget_id}} {{end}} {{#get settings that will also be used in the autogenerate settings dialog. This fills the arrays above}} {{sections[index]="Title"}} {{display_text=get_value 'save_display_text' 'Change Me' 'Text' 'text'}} {{text_size=get_value 'save_text_size' '16' 'Size' 'text'}} {{text_color=get_value 'save_text_color' '#000000' 'Color' 'color'}} {{text_bold=get_value 'save_text_bold' 'on' 'Bold' 'toggle'}} {{# normal display HTML is here. This is what is displayed when viewing the card in non-edit mode}}