def make_icon_state_dict(message_icons, icon_names):
    """Extract the icon state for icon_names from message."""

    def binary_sensor_value(icon_flag):
        return False if icon_flag is None else bool(icon_flag)

    return {k: binary_sensor_value(message_icons[k]) for k in icon_names}