Custom Button Card; change background based on other entity's state

You do not.
Check examples in this button-card repo or look in the main thread (which is a place where all button-card related questions should be asked imho)