Given that you are coordinating data through FireBase, you would probably need to map what you call button Names against branches of your FireBase tree, assuming you track each device in a different branch off the root of the tree, and attributes and controls of each device under that branch?
TinyDB is a good place to keep those mappings between runs.